From patchwork Sun Aug 31 19:07:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 2605 Received: (qmail 12760 invoked by alias); 31 Aug 2014 19:08:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 12736 invoked by uid 89); 31 Aug 2014 19:08:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f180.google.com Received: from mail-pd0-f180.google.com (HELO mail-pd0-f180.google.com) (209.85.192.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 31 Aug 2014 19:08:50 +0000 Received: by mail-pd0-f180.google.com with SMTP id p10so4391257pdj.39 for ; Sun, 31 Aug 2014 12:08:48 -0700 (PDT) X-Received: by 10.70.93.8 with SMTP id cq8mr5075892pdb.160.1409512128577; Sun, 31 Aug 2014 12:08:48 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id dw2sm17025572pab.8.2014.08.31.12.08.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Aug 2014 12:08:48 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH][PR guile/17247] Block SIGCHLD while initializing Guile Date: Sun, 31 Aug 2014 12:07:58 -0700 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. This patch fixes PR 17247. Basically, current Guile (git) starts an internal thread (the "finalizer" thread), and libgc as of 7.4 now starts several marker threads by default (before 7.4.0 one needed to configure libgc with --enable-parallel-mark). When other threads are running, and they haven't blocked SIGCHLD, then the kernel may send SIGCHLD to these threads, leaving gdb hung in the sigsuspend calls in linux-nat.c. P.S. I have a tentative patch for PR 17314, which also fixes 17247, but for a bit of robustness I'm applying both. 2014-08-31 Doug Evans PR 17247 * guile.c: #include . (_initialize_guile): Block SIGCHLD while initializing Guile. Replaces the following, which is reverted. 2014-07-26 Doug Evans 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. diff --git a/gdb/configure.ac b/gdb/configure.ac index 26c8ecf..ab7b1c2 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1233,11 +1233,6 @@ AC_SUBST(GUILE_CPPFLAGS) AC_SUBST(GUILE_LIBS) AM_CONDITIONAL(HAVE_GUILE, test "${have_libguile}" != no) -# PR 17185, see if we can get the libgc version to see if we need -# to apply the workaround. -AC_CHECK_HEADERS(gc/gc.h) -AC_CHECK_FUNCS([setenv]) - # --------------------- # # Check for libmcheck. # # --------------------- # diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 575bb6c..40208d2 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 /* PR 17185 */ -#endif #endif +#include /* The Guile version we're using. We *could* use the macros in libguile/version.h but that would preclude @@ -833,7 +831,9 @@ extern initialize_file_ftype _initialize_guile; void _initialize_guile (void) { - char *msg; +#ifdef HAVE_SIGPROCMASK + sigset_t sigchld_mask, prev_mask; +#endif install_gdb_commands (); @@ -842,16 +842,13 @@ _initialize_guile (void) 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); -#endif +#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. */ + 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. @@ -859,6 +856,10 @@ _initialize_guile (void) (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 + /* 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