guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble joining with threads from C


From: Andy Wingo
Subject: Re: Trouble joining with threads from C
Date: Fri, 18 Mar 2011 13:23:21 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi Mark,

On Wed 09 Mar 2011 07:48, Mark H Weaver <address@hidden> writes:

> Attached are two minimal C programs.  Both create threads that do
> nothing but sleep for 2 seconds and then exit.  The parent tries to join
> with the child thread, with a timeout of 10 seconds.
>
> The only difference is that test1 uses scm_spawn_thread, and test2 uses
> scm_call_with_new_thread.  test1 always times out, and test2 works
> properly.

Indeed, a bug.

> Having looked at the code in threads.c, I'm surprised that either of
> them work.  Both scm_spawn_thread and scm_call_with_new_thread arrange
> for pthread_detach to be called in the child (in spawn_thread and
> launch_thread, respectively).  This is supposed to make the child
> un-joinable.

scm_join_thread_timed doesn't use pthread_join.  I don't recall exactly
why, but its implementation does look OK, at least at first glance.

No, the issue is elsewhere, that the thread-exit handlers were not being
called, which makes me trust our pthreads support much less than before,
if this bug could exist for so long.  I have fixed this in Git with the
attached patch, which fixes your test as well.

Would you mind submitting (and committing :) a test case?  Adding it to
test-suite/standalone is probably the thing to do.

Regards,

Andy

Attachment: 0001-fix-thread-cleanup.patch
Description: Text Data

-- 
http://wingolog.org/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]