From: ludo@gnu.org (Ludovic Courtès)
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: Signal thread
Date: Tue, 28 Jun 2011 18:46:42 +0200 [thread overview]
Message-ID: <87tyb9oqdp.fsf@inria.fr> (raw)
In-Reply-To: 87pqlzt35m.fsf@pobox.com
Hello fellow Guiler of the Guild!
Andy Wingo <wingo@pobox.com> skribis:
> Hello guild-comrade Courtès!
>
> On Mon 27 Jun 2011 18:00, ludo@gnu.org (Ludovic Courtès) writes:
>
>> "Andy Wingo" <wingo@pobox.com> skribis:
>>
>>> commit 3b971a59b55586a236c3621a55515d9272ee5c80
>>> Author: Andy Wingo <wingo@pobox.com>
>>> Date: Thu Jun 23 11:24:16 2011 +0200
>>>
>>> don't spawn the signal delivery thread in a thread-exit handler
>>>
>>> * libguile/threads.c (do_thread_exit): Remove needless spawn of the
>>> signal delivery thread.
>>
>> Out of curiosity, what’s the rationale? Should it be done in stable-2.0
>> as well?
>
> Out of curiosity, I looked :) The commit that added the spawning code
> was 2e77f7202b11ad0003831fcff94ec7db80cca015 from you, which
> unfortunately has no log.
After a moment of shame, I looked at libguile/ChangeLog-2008 and found
evidence that I’m only confederate at worst:
2007-10-20 Julian Graham <joolean@gmail.com>
Add support for thread cancellation and user-defined thread
cleanup handlers. Small rework by Ludovic Courtès.
* null-threads.h (scm_i_pthread_cancel,
scm_i_pthread_cleanup_push, scm_i_pthread_cleanup_pop): New.
* pthread-threads.h (scm_i_pthread_cancel,
scm_i_pthread_cleanup_push, scm_i_pthread_cleanup_pop): New.
* scmsigs.c (scm_i_signal_delivery_thread,
signal_delivery_thread_mutex): New.
(signal_delivery_thread): Leave when `read_without_guile ()'
returns zero.
(start_signal_delivery_thread): Acquire SIGNAL_DELIVERY_THREAD
before spawning the thread. Initialize
SCM_I_SIGNAL_DELIVERY_THREAD.
(ensure_signal_delivery_thread): Renamed to...
(scm_i_ensure_signal_delivery_thread): this.
(scm_i_close_signal_pipe): New.
* scmsigs.h: Updated.
* threads.c (thread_mark): Mark `t->cleanup_handler'.
(guilify_self_1): Initialize `t->cleanup_handler' and
`t->canceled'.
(do_thread_exit): Invoke `t->cleanup_handler'.
(on_thread_exit): Call `scm_i_ensure_signal_delivery_thread ()'.
Call `scm_i_close_signal_pipe ()' when the next-to-last thread
vanishes.
(scm_leave_guile_cleanup): New.
(scm_i_with_guile_and_parent): Use `scm_i_pthread_cleanup_push ()'
and `scm_leave_guile_cleanup ()' to leave guile mode, rather
than call `scm_leave_guile ()' after FUNC.
(scm_cancel_thread, scm_set_thread_cleanup_x,
scm_threads_cleanup): New.
(scm_all_threads): Remove SCM_I_SIGNAL_DELIVERY_THREAD from the
returned list.
* threads.h (scm_i_thread)[cleanup_handler, canceled]: New
fields.
Add declarations of new functions.
Pffew.
The explanation appears to be at
<http://lists.gnu.org/archive/html/guile-devel/2007-10/msg00029.html>:
* If the signal delivery thread got launched a little bit too late, it
could be holding its startup mutex and then attempt to grab the
thread_admin_mutex, which could be held by a thread that was in the
process of being canceled and which was trying to obtain the signal
delivery thread's startup mutex. I've resolved this by forcing the
signal delivery thread to start (if it hasn't already) during thread
cancellation of any thread.
At first sight it still holds.
I checked on ‘stable-2.0’ by applying
3b971a59b55586a236c3621a55515d9272ee5c80 and then running threads.test
under Helgrind, which didn’t report any lock order issue. It could mean
that I was lucky, though.
> Actually, let's take this opportunity to have a moment of silence for
> Arch.
And the terrible tla-cvs-sync!
>> As a side note, why does this area have to change so often? :-)
>
> I understand the frustration :) Threads are hard, signals are hard, GC
> and threads and signals is hard. But I do hope it's getting better.
We have too few tests for the tricky corner cases, but OTOH they are
difficult to write. The number of simpler thread-related tests has
increased though, which probably means we caught a few bugs already, so
there’s hope! ;-)
Thanks,
Ludo’.
next prev parent reply other threads:[~2011-06-28 16:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1QZiQ3-0008H5-HJ@vcs-noshell.in.savannah.gnu.org>
2011-06-27 16:00 ` Signal thread Ludovic Courtès
2011-06-27 20:44 ` Andy Wingo
2011-06-28 16:46 ` Ludovic Courtès [this message]
2011-06-28 19:52 ` Andy Wingo
2011-06-29 15:51 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tyb9oqdp.fsf@inria.fr \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).