From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Doug Evans Newsgroups: gmane.lisp.guile.devel,gmane.comp.gdb.patches Subject: [RFC] Block all async signals used by gdb when initializing Guile Date: Sat, 29 Aug 2015 10:22:11 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1440869008 3204 80.91.229.3 (29 Aug 2015 17:23:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Aug 2015 17:23:28 +0000 (UTC) Cc: guile-devel@gnu.org To: gdb-patches@sourceware.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Aug 29 19:23:23 2015 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZVjqb-0005cr-KR for guile-devel@m.gmane.org; Sat, 29 Aug 2015 19:23:21 +0200 Original-Received: from localhost ([::1]:53678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVjqa-0000ky-RT for guile-devel@m.gmane.org; Sat, 29 Aug 2015 13:23:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVjqX-0000kc-A3 for guile-devel@gnu.org; Sat, 29 Aug 2015 13:23:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVjqT-0005jS-DH for guile-devel@gnu.org; Sat, 29 Aug 2015 13:23:17 -0400 Original-Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]:33570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVjqT-0005j0-5I for guile-devel@gnu.org; Sat, 29 Aug 2015 13:23:13 -0400 Original-Received: by pacgr6 with SMTP id gr6so7854683pac.0 for ; Sat, 29 Aug 2015 10:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:cc:date:message-id:mime-version:content-type; bh=USx+pG2UOvFQ1cJnMBrKuNZqvOSZ4uVi6xmwmDByDQc=; b=HCco/YiDaVVwV7Vv9djp39Qi0BsAUt86Iy0zMNCLKSXdk4N3RJVTrGDAVeiHCrcv0j qHUGN95lgIkvCbZc82fy6HVCCmNu413rlCKHdzQv6LeAYUffkj/GOcVCK8tWymxBYfra uN+YW0RUc8sHvniN0iK69CjDR0Wi3Rec11r3VyP2+Gjegoc/TzB5xz4yNXLLAZpEznIj GQ/OW5YwBoLIeAUMWkx4ZYdvkjJxblP5utkUmo4+XuJjWNjao9vZ8jIlzTG3NH+rGaaE fesu8HOyK48k+IxQuO87lZ4UeuiF8i2jxrV1PK31x/E8soyOiFvU33D10ahOkYHg6LAQ z/BA== X-Received: by 10.68.250.5 with SMTP id yy5mr25032215pbc.34.1440868991673; Sat, 29 Aug 2015 10:23:11 -0700 (PDT) Original-Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by smtp.gmail.com with ESMTPSA id j5sm9227231pdi.7.2015.08.29.10.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Aug 2015 10:23:11 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::235 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17795 gmane.comp.gdb.patches:110695 Archived-At: 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 * 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.