From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 11 21:08:48 2010 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21B7B1065740 for ; Sun, 11 Jul 2010 21:08:48 +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 989798FC12 for ; Sun, 11 Jul 2010 21:08:46 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o6BL8hmr030507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 12 Jul 2010 00:08:43 +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.4/8.14.4) with ESMTP id o6BL8hgP080519; Mon, 12 Jul 2010 00:08:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o6BL8hwW080518; Mon, 12 Jul 2010 00:08:43 +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: Mon, 12 Jul 2010 00:08:43 +0300 From: Kostik Belousov To: Garrett Cooper Message-ID: <20100711210843.GQ2408@deviant.kiev.zoral.com.ua> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/YnR2r17TIEndSCI" Content-Disposition: inline In-Reply-To: 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=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: hackers@freebsd.org Subject: Re: *sigpause hanging on 8.x+ 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: Sun, 11 Jul 2010 21:08:48 -0000 --/YnR2r17TIEndSCI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jul 11, 2010 at 12:39:39PM -0700, Garrett Cooper wrote: > So, long story short... I've basically ported the open posix testsuite > to FreeBSD, and one of the tests tests out sigpause. Unfortunately the > sucker hangs on my dev box at home. >=20 > I've written a short testcase that demonstrates this. It prints out: >=20 > $ ~/test_sigpause > 0 >=20 > And proceeds to be unresponsive to signals (except SIGSTOP / SIGKILL, > as expected). >=20 > When I monkey around with libc's compat4.3 stuff a bit, this is what come= s up: >=20 > $ env LD_LIBRARY_PATH=3D$PWD:/usr/src/lib/libc/../libthr ~/test_sigpause > 0 > before sigemptyset > before _sigsuspend >=20 > So it's getting stuck after calling _sigsuspend. >=20 > I tried the same thing on a i386 8-STABLE VM and it hangs as well. >=20 > I tried applying similar printfs in libthr but it's not hitting that > code at all (it's now responding to SIGTERM though, which is > interesting, but not too interesting to me). >=20 > I also wrote similar code that exercised the functionality in > sigsuspend, by calling sigprocmask beforehand, and it works. >=20 > Thoughts? >=20 > -Garrett >=20 > Dev machine: > FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #1 > r206173:209901M: Sun Jul 11 04:18:42 PDT 2010 > root@:/usr/obj/usr/src/sys/BAYONETTA amd64 > VM: > FreeBSD starr-bastion.localdomain 8.0-STABLE FreeBSD 8.0-STABLE #0 > r207913: Tue May 11 06:21:57 UTC 2010 > root@starr-bastion.localdomain:/usr/obj/usr/src/sys/GENERIC i386 >=20 > Index: compat-43/sigcompat.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- compat-43/sigcompat.c (revision 206173) > +++ compat-43/sigcompat.c (working copy) > @@ -36,6 +36,7 @@ > #include "namespace.h" > #include > #include > +#include > #include > #include "un-namespace.h" > #include "libc_private.h" > @@ -102,7 +103,9 @@ > { > sigset_t set; >=20 > + printf("before sigemptyset\n"); > sigemptyset(&set); > + printf("before _sigsuspend\n"); > set.__bits[0] =3D mask; > return (_sigsuspend(&set)); > } > @@ -111,10 +114,16 @@ > xsi_sigpause(int sig) > { > sigset_t set; > + int rc; >=20 > + printf("before sigemptyset\n"); > sigemptyset(&set); > + printf("before sigaddset\n"); > sigaddset(&set, sig); > - return (_sigsuspend(&set)); > + printf("before _sigsuspend\n"); > + rc =3D (_sigsuspend(&set)); > + printf("after _sigsuspend\n"); > + return rc; > } >=20 > int >=20 > $ cat ~/test_sigpause.c > #include > #include >=20 > int > main (void) > { > printf("0\n"); > fflush(stdout); > (void) sigpause(1); > return 0; > } > $ cat ~/test_sigsuspend.c > #include > #include >=20 > int > main (void) > { > sigset_t oset; > sigset_t nset; > if (sigprocmask(1, &nset, &oset) =3D=3D -1) > err(1, "sigprocmask(-1, &nset, &oset)"); > if (sigprocmask(-1, &nset, &oset) =3D=3D -1) > err(1, "sigprocmask(-1, &nset, &oset)"); > return (sigsuspend(&nset)); > } It seems I got a sigmask for sigpause inside the xsi_sigpause() backward. On the other hand, I do not understand what is your issue with sigpause(). diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c index c3ba30a..bab9d5c 100644 --- a/lib/libc/compat-43/sigcompat.c +++ b/lib/libc/compat-43/sigcompat.c @@ -111,9 +111,12 @@ int xsi_sigpause(int sig) { sigset_t set; + int error; =20 - sigemptyset(&set); - sigaddset(&set, sig); + error =3D _sigprocmask(SIG_BLOCK, NULL, &set); + if (error !=3D 0) + return (error); + sigdelset(&set, sig); return (_sigsuspend(&set)); } =20 --/YnR2r17TIEndSCI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkw6MtoACgkQC3+MBN1Mb4jTqgCg9rdU4eYbrJ3YSADcalr2zg5c M+4An3E/BmQSG1zHdobQ7me8rWMVN0Mk =jeZe -----END PGP SIGNATURE----- --/YnR2r17TIEndSCI--