From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 11 14:45:13 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67B02106566C for ; Wed, 11 Apr 2012 14:45:13 +0000 (UTC) (envelope-from rflynn@acsalaska.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 333D28FC18 for ; Wed, 11 Apr 2012 14:45:13 +0000 (UTC) Received: from [127.0.0.1] (squeeze.lan.rachie.is-a-geek.net [192.168.2.30]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id E2A347E844; Wed, 11 Apr 2012 06:45:11 -0800 (AKDT) Message-ID: <4F8598DC.9010508@acsalaska.net> Date: Wed, 11 Apr 2012 16:44:44 +0200 From: Mel Flynn User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: Ian Lepore References: <4F859112.5070005@acsalaska.net> <1334154373.1082.110.camel@revolution.hippie.lan> In-Reply-To: <1334154373.1082.110.camel@revolution.hippie.lan> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: FreeBSD Hackers Subject: Re: Debugging zombies: pthread_sigmask and sigwait X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2012 14:45:13 -0000 On 4/11/2012 16:26, Ian Lepore wrote: > On Wed, 2012-04-11 at 16:11 +0200, Mel Flynn wrote: >> What happens is that SIGCHLD is never received by the signal thread and >> the child processes turn to zombies. Signal counters never go up, not >> even for SIGINFO, which I added specifically to see if anything gets >> through at all. >> >> The signal thread shows being stuck in sigwait. It's reproducible on >> 8.3-PRERELEASE of a few days ago (r233768). I'm not able to test it on >> anything newer unfortunately, but I suspect this is a bug/linuxism in >> the code not in FreeBSD. > The signal mask for a new thread is inherited from the parent thread. > In your example code, the signal handling thread inherits the blocked > status of the signals as set up in main(). Try adding this line to > signal_handler() before it goes into its while() loop: > > pthread_sigmask(SIG_UNBLOCK, &signal_mask, NULL); That doesn't change anything and is in contrast to what sigwait(2) says: The signals specified by set /should be blocked/ at the time of the call to sigwait(). I also thought about a different child touching the signal code and two processes blocked in sigwait in the original code (they fork a logger process prior to sigemptyset()), but I explicitly avoid that in the test case. -- Mel