* [RFC] Block all async signals used by gdb when initializing Guile
@ 2015-08-29 17:22 Doug Evans
2015-08-29 19:11 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Doug Evans @ 2015-08-29 17:22 UTC (permalink / raw)
To: gdb-patches; +Cc: guile-devel
Hi.
When Guile initializes it will start several GC threads (libgc).
It's important that these threads block SIGCHLD (PR 17247).
This patch extends this to all async signals used by gdb.
One improvement on this patch would be to have event-top.c (or some
such) provide a routine that calls sigaddset for each appropriate
signal rather than defining the list in guile.c.
2015-08-29 Doug Evans <xdje42@gmail.com>
* guile/guile.c (_initialize_guile): Block all asynchronous signals
used by gdb when initializing Guile.
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index 4abf5c5..e9ef70b 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -847,7 +847,7 @@ _initialize_guile (void)
#if HAVE_GUILE
{
#ifdef HAVE_SIGPROCMASK
- sigset_t sigchld_mask, prev_mask;
+ sigset_t guile_init_mask, prev_mask;
#endif
/* The Python support puts the C side in module "_gdb", leaving the Python
@@ -867,9 +867,23 @@ _initialize_guile (void)
have SIGCHLD blocked. PR 17247.
Really libgc and Guile should do this, but we need to work with
libgc 7.4.x. */
- sigemptyset (&sigchld_mask);
- sigaddset (&sigchld_mask, SIGCHLD);
- sigprocmask (SIG_BLOCK, &sigchld_mask, &prev_mask);
+ sigemptyset (&guile_init_mask);
+ sigaddset (&guile_init_mask, SIGCHLD);
+ /* Also block other asynchronous signals used by GDB. See event-top.c.
+ Really we want to block every signal here except for those specifically
+ used by Guile (e.g., GC threads), but this is safer for now. */
+ sigaddset (&guile_init_mask, SIGINT);
+ sigaddset (&guile_init_mask, SIGTERM);
+#ifdef SIGQUIT
+ sigaddset (&guile_init_mask, SIGQUIT);
+#endif
+#ifdef SIGHUP
+ sigaddset (&guile_init_mask, SIGHUP);
+#endif
+#ifdef SIGWINCH
+ sigaddset (&guile_init_mask, SIGWINCH);
+#endif
+ sigprocmask (SIG_BLOCK, &guile_init_mask, &prev_mask);
#endif
/* scm_with_guile is the most portable way to initialize Guile.
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-08-29 17:22 [RFC] Block all async signals used by gdb when initializing Guile Doug Evans
@ 2015-08-29 19:11 ` Eli Zaretskii
2015-08-29 19:20 ` Doug Evans
0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2015-08-29 19:11 UTC (permalink / raw)
To: Doug Evans; +Cc: guile-devel, gdb-patches
> From: Doug Evans <xdje42@gmail.com>
> cc: guile-devel@gnu.org
> Date: Sat, 29 Aug 2015 10:22:11 -0700
>
> --- a/gdb/guile/guile.c
> +++ b/gdb/guile/guile.c
> @@ -847,7 +847,7 @@ _initialize_guile (void)
> #if HAVE_GUILE
> {
> #ifdef HAVE_SIGPROCMASK
> - sigset_t sigchld_mask, prev_mask;
> + sigset_t guile_init_mask, prev_mask;
> #endif
>
> /* The Python support puts the C side in module "_gdb", leaving the Python
> @@ -867,9 +867,23 @@ _initialize_guile (void)
> have SIGCHLD blocked. PR 17247.
> Really libgc and Guile should do this, but we need to work with
> libgc 7.4.x. */
> - sigemptyset (&sigchld_mask);
> - sigaddset (&sigchld_mask, SIGCHLD);
> - sigprocmask (SIG_BLOCK, &sigchld_mask, &prev_mask);
> + sigemptyset (&guile_init_mask);
> + sigaddset (&guile_init_mask, SIGCHLD);
> + /* Also block other asynchronous signals used by GDB. See event-top.c.
> + Really we want to block every signal here except for those specifically
> + used by Guile (e.g., GC threads), but this is safer for now. */
> + sigaddset (&guile_init_mask, SIGINT);
> + sigaddset (&guile_init_mask, SIGTERM);
> +#ifdef SIGQUIT
> + sigaddset (&guile_init_mask, SIGQUIT);
> +#endif
> +#ifdef SIGHUP
> + sigaddset (&guile_init_mask, SIGHUP);
> +#endif
> +#ifdef SIGWINCH
> + sigaddset (&guile_init_mask, SIGWINCH);
> +#endif
> + sigprocmask (SIG_BLOCK, &guile_init_mask, &prev_mask);
> #endif
What about platforms that don't have sigprocmask, but do have SIGINT?
Don't we want to block SIGINT on those platforms?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-08-29 19:11 ` Eli Zaretskii
@ 2015-08-29 19:20 ` Doug Evans
2015-08-29 20:16 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Doug Evans @ 2015-08-29 19:20 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: guile-devel, gdb-patches@sourceware.org
On Sat, Aug 29, 2015 at 12:11 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Doug Evans <xdje42@gmail.com>
>> cc: guile-devel@gnu.org
>> Date: Sat, 29 Aug 2015 10:22:11 -0700
>>
>> --- a/gdb/guile/guile.c
>> +++ b/gdb/guile/guile.c
>> @@ -847,7 +847,7 @@ _initialize_guile (void)
>> #if HAVE_GUILE
>> {
>> #ifdef HAVE_SIGPROCMASK
>> - sigset_t sigchld_mask, prev_mask;
>> + sigset_t guile_init_mask, prev_mask;
>> #endif
>>
>> /* The Python support puts the C side in module "_gdb", leaving the Python
>> @@ -867,9 +867,23 @@ _initialize_guile (void)
>> have SIGCHLD blocked. PR 17247.
>> Really libgc and Guile should do this, but we need to work with
>> libgc 7.4.x. */
>> - sigemptyset (&sigchld_mask);
>> - sigaddset (&sigchld_mask, SIGCHLD);
>> - sigprocmask (SIG_BLOCK, &sigchld_mask, &prev_mask);
>> + sigemptyset (&guile_init_mask);
>> + sigaddset (&guile_init_mask, SIGCHLD);
>> + /* Also block other asynchronous signals used by GDB. See event-top.c.
>> + Really we want to block every signal here except for those specifically
>> + used by Guile (e.g., GC threads), but this is safer for now. */
>> + sigaddset (&guile_init_mask, SIGINT);
>> + sigaddset (&guile_init_mask, SIGTERM);
>> +#ifdef SIGQUIT
>> + sigaddset (&guile_init_mask, SIGQUIT);
>> +#endif
>> +#ifdef SIGHUP
>> + sigaddset (&guile_init_mask, SIGHUP);
>> +#endif
>> +#ifdef SIGWINCH
>> + sigaddset (&guile_init_mask, SIGWINCH);
>> +#endif
>> + sigprocmask (SIG_BLOCK, &guile_init_mask, &prev_mask);
>> #endif
>
> What about platforms that don't have sigprocmask, but do have SIGINT?
> Don't we want to block SIGINT on those platforms?
Do they have threads, and how does one block SIGINT on those platforms?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-08-29 19:20 ` Doug Evans
@ 2015-08-29 20:16 ` Eli Zaretskii
2015-08-29 20:39 ` Doug Evans
0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2015-08-29 20:16 UTC (permalink / raw)
To: Doug Evans; +Cc: guile-devel, gdb-patches
> Date: Sat, 29 Aug 2015 12:20:24 -0700
> From: Doug Evans <xdje42@gmail.com>
> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, guile-devel <guile-devel@gnu.org>
>
> > What about platforms that don't have sigprocmask, but do have SIGINT?
> > Don't we want to block SIGINT on those platforms?
>
> Do they have threads
They might. (The only way I've succeeded to have a working Guile on
Windows was to disable threads, but I hope that bug will be fixed one
day.)
> and how does one block SIGINT on those platforms?
With a call to 'signal', I guess.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-08-29 20:16 ` Eli Zaretskii
@ 2015-08-29 20:39 ` Doug Evans
2015-08-29 21:04 ` Mark Kettenis
2015-08-30 2:35 ` Eli Zaretskii
0 siblings, 2 replies; 12+ messages in thread
From: Doug Evans @ 2015-08-29 20:39 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: guile-devel, gdb-patches@sourceware.org
On Sat, Aug 29, 2015 at 1:16 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sat, 29 Aug 2015 12:20:24 -0700
>> From: Doug Evans <xdje42@gmail.com>
>> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, guile-devel <guile-devel@gnu.org>
>>
>> > What about platforms that don't have sigprocmask, but do have SIGINT?
>> > Don't we want to block SIGINT on those platforms?
>>
>> Do they have threads
>
> They might. (The only way I've succeeded to have a working Guile on
> Windows was to disable threads, but I hope that bug will be fixed one
> day.)
>
>> and how does one block SIGINT on those platforms?
>
> With a call to 'signal', I guess.
I'm guessing that won't work here, we'll need something else.
The issue is we need the threads that guile starts
to have these signals blocked. Then after guile init
returns we unblock the signals.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-08-29 20:39 ` Doug Evans
@ 2015-08-29 21:04 ` Mark Kettenis
2015-08-30 2:37 ` Eli Zaretskii
2015-08-30 2:35 ` Eli Zaretskii
1 sibling, 1 reply; 12+ messages in thread
From: Mark Kettenis @ 2015-08-29 21:04 UTC (permalink / raw)
To: xdje42; +Cc: eliz, gdb-patches, guile-devel
> Date: Sat, 29 Aug 2015 13:39:55 -0700
> From: Doug Evans <xdje42@gmail.com>
>
> On Sat, Aug 29, 2015 at 1:16 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> Date: Sat, 29 Aug 2015 12:20:24 -0700
> >> From: Doug Evans <xdje42@gmail.com>
> >> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, guile-devel <guile-devel@gnu.org>
> >>
> >> > What about platforms that don't have sigprocmask, but do have SIGINT?
> >> > Don't we want to block SIGINT on those platforms?
> >>
> >> Do they have threads
> >
> > They might. (The only way I've succeeded to have a working Guile on
> > Windows was to disable threads, but I hope that bug will be fixed one
> > day.)
> >
> >> and how does one block SIGINT on those platforms?
> >
> > With a call to 'signal', I guess.
>
> I'm guessing that won't work here, we'll need something else.
> The issue is we need the threads that guile starts
> to have these signals blocked. Then after guile init
> returns we unblock the signals.
I suppose blocking these in the threads that guile starts is necessary
because that is the only way to guarantee that those signals will be
delivered to the main gdb thread on POSIX systems.
On Windows you probably need to do something completely different.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-08-29 21:04 ` Mark Kettenis
@ 2015-08-30 2:37 ` Eli Zaretskii
2015-09-01 5:05 ` Doug Evans
0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2015-08-30 2:37 UTC (permalink / raw)
To: Mark Kettenis; +Cc: guile-devel, gdb-patches
> Date: Sat, 29 Aug 2015 23:04:02 +0200 (CEST)
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> CC: eliz@gnu.org, gdb-patches@sourceware.org, guile-devel@gnu.org
>
> I suppose blocking these in the threads that guile starts is necessary
> because that is the only way to guarantee that those signals will be
> delivered to the main gdb thread on POSIX systems.
>
> On Windows you probably need to do something completely different.
I might be missing something, because I don't see why.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-08-30 2:37 ` Eli Zaretskii
@ 2015-09-01 5:05 ` Doug Evans
2015-09-01 14:35 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Doug Evans @ 2015-09-01 5:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: guile-devel, gdb-patches@sourceware.org, Mark Kettenis
On Sat, Aug 29, 2015 at 7:37 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sat, 29 Aug 2015 23:04:02 +0200 (CEST)
>> From: Mark Kettenis <mark.kettenis@xs4all.nl>
>> CC: eliz@gnu.org, gdb-patches@sourceware.org, guile-devel@gnu.org
>>
>> I suppose blocking these in the threads that guile starts is necessary
>> because that is the only way to guarantee that those signals will be
>> delivered to the main gdb thread on POSIX systems.
>>
>> On Windows you probably need to do something completely different.
>
> I might be missing something, because I don't see why.
The goal here is to block these signals from being sent to the threads
that Guile (or more specifically libgc) creates.
Posix threads inherit the current value of the process's sigmask,
so as long as the threads are started during Guile initialization,
we can achieve this by blocking the signals before calling Guile's init
routine and then restoring them after Guile's init routine returns.
Note that we don't want to prevent gdb from getting the signals,
we just want them to be sent to gdb's main thread.
Not sure how to do that on windows.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-09-01 5:05 ` Doug Evans
@ 2015-09-01 14:35 ` Eli Zaretskii
2015-09-01 15:22 ` Doug Evans
0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2015-09-01 14:35 UTC (permalink / raw)
To: Doug Evans; +Cc: guile-devel, gdb-patches, mark.kettenis
> Date: Mon, 31 Aug 2015 22:05:59 -0700
> From: Doug Evans <xdje42@gmail.com>
> Cc: Mark Kettenis <mark.kettenis@xs4all.nl>,
> "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, guile-devel <guile-devel@gnu.org>
>
> On Sat, Aug 29, 2015 at 7:37 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> Date: Sat, 29 Aug 2015 23:04:02 +0200 (CEST)
> >> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> >> CC: eliz@gnu.org, gdb-patches@sourceware.org, guile-devel@gnu.org
> >>
> >> I suppose blocking these in the threads that guile starts is necessary
> >> because that is the only way to guarantee that those signals will be
> >> delivered to the main gdb thread on POSIX systems.
> >>
> >> On Windows you probably need to do something completely different.
> >
> > I might be missing something, because I don't see why.
>
> The goal here is to block these signals from being sent to the threads
> that Guile (or more specifically libgc) creates.
Why only libgc? Don't we want to block these signals in any Guile
code invoked later by GDB?
> Not sure how to do that on windows.
That problem doesn't exist on Windows, but what about Guile
application threads launched later?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-09-01 14:35 ` Eli Zaretskii
@ 2015-09-01 15:22 ` Doug Evans
2015-09-01 15:50 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Doug Evans @ 2015-09-01 15:22 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: guile-devel, gdb-patches@sourceware.org, Mark Kettenis
On Tue, Sep 1, 2015 at 7:35 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> The goal here is to block these signals from being sent to the threads
>> that Guile (or more specifically libgc) creates.
>
> Why only libgc? Don't we want to block these signals in any Guile
> code invoked later by GDB?
Any threads created later are required to DTRT themselves.
[Same as on python.]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-09-01 15:22 ` Doug Evans
@ 2015-09-01 15:50 ` Eli Zaretskii
0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2015-09-01 15:50 UTC (permalink / raw)
To: Doug Evans; +Cc: guile-devel, gdb-patches, mark.kettenis
> Date: Tue, 1 Sep 2015 08:22:44 -0700
> From: Doug Evans <xdje42@gmail.com>
> Cc: Mark Kettenis <mark.kettenis@xs4all.nl>,
> "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, guile-devel <guile-devel@gnu.org>
>
> On Tue, Sep 1, 2015 at 7:35 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> The goal here is to block these signals from being sent to the threads
> >> that Guile (or more specifically libgc) creates.
> >
> > Why only libgc? Don't we want to block these signals in any Guile
> > code invoked later by GDB?
>
> Any threads created later are required to DTRT themselves.
> [Same as on python.]
Then I guess this problem can be ignored for Windows.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Block all async signals used by gdb when initializing Guile
2015-08-29 20:39 ` Doug Evans
2015-08-29 21:04 ` Mark Kettenis
@ 2015-08-30 2:35 ` Eli Zaretskii
1 sibling, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2015-08-30 2:35 UTC (permalink / raw)
To: Doug Evans; +Cc: guile-devel, gdb-patches
> Date: Sat, 29 Aug 2015 13:39:55 -0700
> From: Doug Evans <xdje42@gmail.com>
> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, guile-devel <guile-devel@gnu.org>
>
> On Sat, Aug 29, 2015 at 1:16 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> Date: Sat, 29 Aug 2015 12:20:24 -0700
> >> From: Doug Evans <xdje42@gmail.com>
> >> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, guile-devel <guile-devel@gnu.org>
> >>
> >> > What about platforms that don't have sigprocmask, but do have SIGINT?
> >> > Don't we want to block SIGINT on those platforms?
> >>
> >> Do they have threads
> >
> > They might. (The only way I've succeeded to have a working Guile on
> > Windows was to disable threads, but I hope that bug will be fixed one
> > day.)
> >
> >> and how does one block SIGINT on those platforms?
> >
> > With a call to 'signal', I guess.
>
> I'm guessing that won't work here, we'll need something else.
I don't understand why. Can you explain? Maybe I'm missing
something.
> The issue is we need the threads that guile starts
> to have these signals blocked. Then after guile init
> returns we unblock the signals.
Inhibit SIGINT ech time before calling Guile and restore it after
Guile returns. Wouldn't that do what you want?
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-09-01 15:50 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-29 17:22 [RFC] Block all async signals used by gdb when initializing Guile Doug Evans
2015-08-29 19:11 ` Eli Zaretskii
2015-08-29 19:20 ` Doug Evans
2015-08-29 20:16 ` Eli Zaretskii
2015-08-29 20:39 ` Doug Evans
2015-08-29 21:04 ` Mark Kettenis
2015-08-30 2:37 ` Eli Zaretskii
2015-09-01 5:05 ` Doug Evans
2015-09-01 14:35 ` Eli Zaretskii
2015-09-01 15:22 ` Doug Evans
2015-09-01 15:50 ` Eli Zaretskii
2015-08-30 2:35 ` Eli Zaretskii
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).