aboutsummaryrefslogtreecommitdiff
path: root/gdb/guile/guile.c
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2014-09-08 22:45:34 -0700
committerDoug Evans <xdje42@gmail.com>2014-09-08 22:45:34 -0700
commit92d8d229d9a310ebfcfc13bf4a75a286c1add1ac (patch)
treeb9ce9674fc04930b500d611e033bb5368c9d54a3 /gdb/guile/guile.c
parent837405970476d31d6b4d7774e2c914fdfa7a9930 (diff)
downloadgdb-92d8d229d9a310ebfcfc13bf4a75a286c1add1ac.zip
gdb-92d8d229d9a310ebfcfc13bf4a75a286c1add1ac.tar.gz
gdb-92d8d229d9a310ebfcfc13bf4a75a286c1add1ac.tar.bz2
Fix for PR 17247: Block SIGCHLD while initializing Guile.
The problem here is that if a thread other than gdb's main thread gets a SIGCHLD (it's an asynchronous signal so the kernel will essentially pick a random thread) then gdb will hang if it is in sigsuspend when the SIGCHLD is delivered. The other thread will see the signal and the sigsuspend won't "wake up". Guile and libgc should be blocking SIGCHLD in their threads, but we need to work with Guile 2.0 and libgc 7.4. The problem first shows up in libgc 7.4 because it is the first release that enables multiple marker threads by default. gdb/ChangeLog: PR 17247 * guile.c: #include <signal.h>. (_initialize_guile): Block SIGCHLD while initializing Guile. Replaces the following, which is reverted. 2014-07-26 Doug Evans <xdje42@gmail.com> PR 17185 * configure.ac: Add check for header gc/gc.h. Add check for function setenv. * configure: Regenerate. * config.in: Regenerate. * guile/guile.c (_initialize_guile): Add workaround for libgc 7.4.0.
Diffstat (limited to 'gdb/guile/guile.c')
-rw-r--r--gdb/guile/guile.c67
1 files changed, 36 insertions, 31 deletions
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index 575bb6c..97da042 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -34,10 +34,8 @@
#ifdef HAVE_GUILE
#include "guile.h"
#include "guile-internal.h"
-#ifdef HAVE_GC_GC_H
-#include <gc/gc.h> /* PR 17185 */
-#endif
#endif
+#include <signal.h>
/* The Guile version we're using.
We *could* use the macros in libguile/version.h but that would preclude
@@ -833,39 +831,46 @@ extern initialize_file_ftype _initialize_guile;
void
_initialize_guile (void)
{
- char *msg;
-
install_gdb_commands ();
#if HAVE_GUILE
- /* The Python support puts the C side in module "_gdb", leaving the Python
- side to define module "gdb" which imports "_gdb". There is evidently no
- similar convention in Guile so we skip this. */
-
- /* PR 17185 There are problems with using libgc 7.4.0.
- Copy over the workaround Guile uses (Guile is working around a different
- problem, but the workaround is the same). */
-#if (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR == 4 && GC_VERSION_MICRO == 0)
- /* The bug is only known to appear with pthreads. We assume any system
- using pthreads also uses setenv (and not putenv). That is why we don't
- have a similar call to putenv here. */
-#if defined (HAVE_SETENV)
- setenv ("GC_MARKERS", "1", 1);
+ {
+#ifdef HAVE_SIGPROCMASK
+ sigset_t sigchld_mask, prev_mask;
#endif
+
+ /* The Python support puts the C side in module "_gdb", leaving the Python
+ side to define module "gdb" which imports "_gdb". There is evidently no
+ similar convention in Guile so we skip this. */
+
+#ifdef HAVE_SIGPROCMASK
+ /* Before we initialize Guile, block SIGCHLD.
+ This is done so that all threads created during Guile initialization
+ 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);
+#endif
+
+ /* scm_with_guile is the most portable way to initialize Guile.
+ Plus we need to initialize the Guile support while in Guile mode
+ (e.g., called from within a call to scm_with_guile). */
+ scm_with_guile (call_initialize_gdb_module, NULL);
+
+#ifdef HAVE_SIGPROCMASK
+ sigprocmask (SIG_SETMASK, &prev_mask, NULL);
#endif
- /* scm_with_guile is the most portable way to initialize Guile.
- Plus we need to initialize the Guile support while in Guile mode
- (e.g., called from within a call to scm_with_guile). */
- scm_with_guile (call_initialize_gdb_module, NULL);
-
- /* Set Guile's backtrace to match the "set guile print-stack" default.
- [N.B. The two settings are still separate.]
- But only do this after we've initialized Guile, it's nice to see a
- backtrace if there's an error during initialization.
- OTOH, if the error is that gdb/init.scm wasn't found because gdb is being
- run from the build tree, the backtrace is more noise than signal.
- Sigh. */
- gdbscm_set_backtrace (0);
+ /* Set Guile's backtrace to match the "set guile print-stack" default.
+ [N.B. The two settings are still separate.]
+ But only do this after we've initialized Guile, it's nice to see a
+ backtrace if there's an error during initialization.
+ OTOH, if the error is that gdb/init.scm wasn't found because gdb is
+ being run from the build tree, the backtrace is more noise than signal.
+ Sigh. */
+ gdbscm_set_backtrace (0);
+ }
#endif
}