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 Subject: Need to block SIGCHLD in libgc and guile internal threads Date: Tue, 26 Aug 2014 01:14:46 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1409040909 7048 80.91.229.3 (26 Aug 2014 08:15:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Aug 2014 08:15:09 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Aug 26 10:15:04 2014 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 1XMBuB-00017g-9X for guile-devel@m.gmane.org; Tue, 26 Aug 2014 10:15:03 +0200 Original-Received: from localhost ([::1]:52472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMBu2-0001yk-9s for guile-devel@m.gmane.org; Tue, 26 Aug 2014 04:14:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMBty-0001yd-6h for guile-devel@gnu.org; Tue, 26 Aug 2014 04:14:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMBtu-00068U-TC for guile-devel@gnu.org; Tue, 26 Aug 2014 04:14:50 -0400 Original-Received: from mail-yh0-x233.google.com ([2607:f8b0:4002:c01::233]:44287) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMBtu-00068P-PP for guile-devel@gnu.org; Tue, 26 Aug 2014 04:14:46 -0400 Original-Received: by mail-yh0-f51.google.com with SMTP id f73so11546859yha.38 for ; Tue, 26 Aug 2014 01:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=hTgSoIQVTvfqgf++4ZQfoGF5K2vWiOy0QItmhMguEUU=; b=H+NcLnxB3jCzBo6BWci70tuVctSUhR0u66JgPxsxh16m053ajqvP3qw13xer8z7fCP xp++RAQSVNDVs7difWwSiSSZ9aXBqG99/M4kWK+SP7IZa89bD0p9WPWDBj/7rmU8QNtv vZanDhXBFROFLTdpkJ2fBdaGcOm6C+ZX7Sy/ZcTFCStq2iLD51mfFRBV0kf1WqAOG0tT J5DRkQDIEO4MZHXSCtXl4rVMSfNfkzgvLhuolU+CnDVNNNYUaO9vc3Yyq9cyLOX00c8t B60c5KV5vhQuC9JyOwB4iKRz2JDXtoImD/moU1hUlAS8ZHYny8PL9icEZH/v0wOC04Bl nRsA== X-Received: by 10.236.66.171 with SMTP id h31mr76210yhd.131.1409040886075; Tue, 26 Aug 2014 01:14:46 -0700 (PDT) Original-Received: by 10.170.66.138 with HTTP; Tue, 26 Aug 2014 01:14:46 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c01::233 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:17370 Archived-At: Hi. I think(!) I understand why gdb is hanging when used with libgc 7.4.x. This is gdb bug 17247. https://sourceware.org/bugzilla/show_bug.cgi?id=17247#c30 First, libgc 7.4.x was the first release to default PARALLEL_MARK to on, so I'm guessing the same "bug" exists in 7.2, it's just not visible unless one builds libgc with --enable-parallel-mark. gdb/linux-nat.c calls sigsuspend when the inferior is running and gdb needs to wait for it to stop. gdb is waiting on a SIGCHLD at this point. However, if the SIGCHLD goes to a different thread, say the guile finalizer thread or a libgc marker thread then the sigsuspend that gdb calls doesn't wake up and gdb is hung. So question: Any suggestions for how to approach this? Here's the hack that I applied to Guile to see if this removes the gdb hang. I'm not suggesting checking this in. It's just data to help advance the discussion. I think there's a general issue here that these threads should block every signal they're not expecting, or at least provide a hook to let the app specify which signals to block. gdb's need to use SIGCHLD is just one example of a general problem. diff --git a/libguile/finalizers.c b/libguile/finalizers.c index 82f292c..95a022c 100644 --- a/libguile/finalizers.c +++ b/libguile/finalizers.c @@ -239,6 +239,12 @@ finalization_thread_proc (void *unused) static void* run_finalization_thread (void *arg) { + { + sigset_t blocked_mask; + sigemptyset (&blocked_mask); + sigaddset (&blocked_mask, SIGCHLD); + sigprocmask (SIG_BLOCK, &blocked_mask, NULL); + } return scm_with_guile (finalization_thread_proc, arg); }