From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 11 15:25:30 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8EFBE1065676 for ; Wed, 11 Apr 2012 15:25:30 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta12.emeryville.ca.mail.comcast.net (qmta12.emeryville.ca.mail.comcast.net [76.96.27.227]) by mx1.freebsd.org (Postfix) with ESMTP id 6D8CC8FC25 for ; Wed, 11 Apr 2012 15:25:30 +0000 (UTC) Received: from omta08.emeryville.ca.mail.comcast.net ([76.96.30.12]) by qmta12.emeryville.ca.mail.comcast.net with comcast id wfPu1i0070FhH24ACfRQFi; Wed, 11 Apr 2012 15:25:24 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta08.emeryville.ca.mail.comcast.net with comcast id wfRN1i00Y4NgCEG8UfRPmU; Wed, 11 Apr 2012 15:25:24 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q3BFPLWH059284; Wed, 11 Apr 2012 09:25:21 -0600 (MDT) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: Konstantin Belousov In-Reply-To: <20120411144703.GM2358@deviant.kiev.zoral.com.ua> References: <4F859112.5070005@acsalaska.net> <1334154373.1082.110.camel@revolution.hippie.lan> <20120411144703.GM2358@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset="us-ascii" Date: Wed, 11 Apr 2012 09:25:21 -0600 Message-ID: <1334157921.1082.111.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: FreeBSD Hackers , Mel Flynn 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 15:25:30 -0000 On Wed, 2012-04-11 at 17:47 +0300, Konstantin Belousov wrote: > On Wed, Apr 11, 2012 at 08:26:13AM -0600, Ian Lepore wrote: > > On Wed, 2012-04-11 at 16:11 +0200, Mel Flynn wrote: > > > Hi, > > > > > > I'm currently stuck on a bug in Zarafa-spooler that creates zombies. and > > > working around it by claiming that our pthread library isn't "normal" > > > which uses standard signals rather then a signal thread. > > > > > > My limited understanding of these facilities is however not enough to > > > see the actual problem here and reading of related manpages did not lead > > > me to a solution either. A test case reproducing the problem is attached. > > > > > > 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. > > > > > > Thanks in advance for any insights. > > > _______________________________________________ > > > freebsd-hackers@freebsd.org mailing list > > > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > > > 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); > > This is completely wrong. sigwait(2) requires the waited signals to be > blocked, so the code is right in this regard. > Ooops, sorry. The code that sets up our signal handling threads uses SIG_SETMASK rather than BLOCK/UNBLOCK, and my quick glance at it misinterpretted what it was doing. -- Ian