From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 11 14:47:31 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 27DA01065672 for ; Wed, 11 Apr 2012 14:47:31 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id B60AE8FC0A for ; Wed, 11 Apr 2012 14:47:30 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q3BEl4wl031962; Wed, 11 Apr 2012 17:47:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q3BEl4LL004098; Wed, 11 Apr 2012 17:47:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q3BEl33I004097; Wed, 11 Apr 2012 17:47:03 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 11 Apr 2012 17:47:03 +0300 From: Konstantin Belousov To: Ian Lepore Message-ID: <20120411144703.GM2358@deviant.kiev.zoral.com.ua> References: <4F859112.5070005@acsalaska.net> <1334154373.1082.110.camel@revolution.hippie.lan> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EontnEYYSB34MdTw" Content-Disposition: inline In-Reply-To: <1334154373.1082.110.camel@revolution.hippie.lan> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua 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 14:47:31 -0000 --EontnEYYSB34MdTw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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, > >=20 > > 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. > >=20 > > 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 attache= d. > >=20 > > 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. > >=20 > > 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. > >=20 > > 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.o= rg" >=20 > 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: >=20 > 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. What happens, as I guess it, the SIGINFO and SIGCHLD are ignored, so kernel do not even bother to queue the signals to the master process. Register a dummy signal handler for your signals with sigaction before creating 'signal_handler' thread. --EontnEYYSB34MdTw Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+FmWcACgkQC3+MBN1Mb4g21wCfe9r+dXNxfVNllIS5PYUc+Qdb ELcAn3lVshYCjbPyxtQMb/2vosmK2d8l =+hSJ -----END PGP SIGNATURE----- --EontnEYYSB34MdTw--