From owner-freebsd-threads@FreeBSD.ORG Sat Feb 19 19:42:47 2011 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D8997106566B for ; Sat, 19 Feb 2011 19:42:47 +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 746BA8FC0A for ; Sat, 19 Feb 2011 19:42: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 p1JJghiC068034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 19 Feb 2011 21:42:43 +0200 (EET) (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 p1JJgh7T029095; Sat, 19 Feb 2011 21:42:43 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p1JJghi4029094; Sat, 19 Feb 2011 21:42:43 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 19 Feb 2011 21:42:43 +0200 From: Kostik Belousov To: KOSAKI Motohiro Message-ID: <20110219194243.GL78089@deviant.kiev.zoral.com.ua> References: <201102191809.p1JI9rZi063561@red.freebsd.org> <20110219184348.GK78089@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fBKP4Km0jCX9yvBB" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, 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: freebsd-threads@freebsd.org Subject: Re: threads/154893: pthread_sigmask don't work if mask and oldmask are passed the same pointer X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Feb 2011 19:42:47 -0000 --fBKP4Km0jCX9yvBB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 20, 2011 at 04:22:46AM +0900, KOSAKI Motohiro wrote: > > Your example does not supply oset =3D=3D set to the pthread_sigmask, > > meantime. I really do not see anything wrong with the output of > > the program that supposed to illustrate the issue. >=20 > Oh, I'm sorry. It's cut-n-paste mistake. I did paste old version > unintensionally. >=20 > void* func2(void* arg) > { > sigset_t old; > sigset_t add; > int i; >=20 > sigemptyset(&old); > pthread_sigmask(SIG_BLOCK, NULL, &old); >=20 > printf("before: "); > for (i=3D0; i<4; i++) > printf(" %08x", old.__bits[i]); > printf("\n"); >=20 > sigemptyset(&add); > sigaddset(&add, SIGUSR1); > pthread_sigmask(SIG_BLOCK, &add, &add); > pthread_sigmask(SIG_BLOCK, NULL, &old); >=20 > printf("after: "); > for (i=3D0; i<4; i++) > printf(" %08x", old.__bits[i]); > printf("\n"); >=20 > return 0; > } >=20 > The result is, >=20 > correct case: > before: 00000000 00000000 00000000 00000000 > after: 20000000 00000000 00000000 00000000 > incorrect case: > before: 00000000 00000000 00000000 00000000 > after: 00000000 00000000 00000000 00000000 >=20 > difference between func and func2 are >=20 > - pthread_sigmask(SIG_BLOCK, &add, NULL); > + pthread_sigmask(SIG_BLOCK, &add, &add); >=20 > That said, To add oset changed sigprocmask() behavior significantly. Still something is not right :). I copied/pasted the updated func2() from the mail above, and get correct case:=20 before: 00000000 00000000 00000000 00000000 after: 20000000 00000000 00000000 00000000 incorrect case:=20 before: 00000000 00000000 00000000 00000000 after: 20000000 00000000 00000000 00000000 on amd64 machine, while code is compiled for 32 bit. I would say that the output is as expected by me. The old mask is copied out by kernel after new mask is copied in. Below is the exact source of the test I used. Could you, please, confirm that the test is right ? If not, please send me the exact source code that demonstrates your issue. Thanks. #include #include #include void* func(void* arg) { sigset_t old; sigset_t add; int i; sigemptyset(&old); pthread_sigmask(SIG_BLOCK, NULL, &old); printf("before: "); for (i=3D0; i<4; i++) printf(" %08x", old.__bits[i]); printf("\n"); sigemptyset(&add); sigaddset(&add, SIGUSR1); pthread_sigmask(SIG_BLOCK, &add, NULL); pthread_sigmask(SIG_BLOCK, NULL, &old); printf("after: "); for (i=3D0; i<4; i++) printf(" %08x", old.__bits[i]); printf("\n"); return 0; } void* func2(void* arg) { sigset_t old; sigset_t add; int i; sigemptyset(&old); pthread_sigmask(SIG_BLOCK, NULL, &old); printf("before: "); for (i=3D0; i<4; i++) printf(" %08x", old.__bits[i]); printf("\n"); sigemptyset(&add); sigaddset(&add, SIGUSR1); pthread_sigmask(SIG_BLOCK, &add, &add); pthread_sigmask(SIG_BLOCK, NULL, &old); printf("after: "); for (i=3D0; i<4; i++) printf(" %08x", old.__bits[i]); printf("\n"); return 0; } int main(void) { pthread_t thr; void* ret; printf("correct case: \n"); pthread_create(&thr, NULL, func, NULL); pthread_join(thr, &ret); printf("incorrect case: \n"); pthread_create(&thr, NULL, func2, NULL); pthread_join(thr, &ret); return 0; } --fBKP4Km0jCX9yvBB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk1gHTIACgkQC3+MBN1Mb4iEbQCg3whUHY7l0Wd98PuzJWT/Ud2H cFYAn1qOqx8XJRwo4cemsYlUGvAhPkxs =F2XK -----END PGP SIGNATURE----- --fBKP4Km0jCX9yvBB--