From owner-freebsd-stable@FreeBSD.ORG Tue Nov 24 15:34:27 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B326C106566B for ; Tue, 24 Nov 2009 15:34:27 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (skuns.zoral.com.ua [91.193.166.194]) by mx1.freebsd.org (Postfix) with ESMTP id 2ACD38FC12 for ; Tue, 24 Nov 2009 15:34:26 +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 nAOFYMff097023 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 24 Nov 2009 17:34:22 +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.3/8.14.3) with ESMTP id nAOFYMtd089187; Tue, 24 Nov 2009 17:34:22 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id nAOFYMRA089186; Tue, 24 Nov 2009 17:34:22 +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: Tue, 24 Nov 2009 17:34:22 +0200 From: Kostik Belousov To: Mikolaj Golub Message-ID: <20091124153422.GT2331@deviant.kiev.zoral.com.ua> References: <86aayc7z4g.fsf@zhuzha.ua1> <8663907xyy.fsf@zhuzha.ua1> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="i616tqyc3hrkKsk2" Content-Disposition: inline In-Reply-To: <8663907xyy.fsf@zhuzha.ua1> 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.4 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 Stable Subject: Re: pthread.h: typo in #define pthread_cleanup_push/pthread_cleanup_pop X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Nov 2009 15:34:27 -0000 --i616tqyc3hrkKsk2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 24, 2009 at 05:18:29PM +0200, Mikolaj Golub wrote: > On Tue, 24 Nov 2009 16:53:35 +0200 Mikolaj Golub wrote: >=20 > > Hi, > > > > I have problems with compiling our application under 8.0. > > > > It fails due to these definitions in pthread.h that look like a typo or > > incorrectly applied patch: > > > > 170 #define pthread_cleanup_push(cleanup_routine, cleanup_a= rg) \ > > 171 { = \ > > 172 struct _pthread_cleanup_info __cleanup_= info__; \ > > 173 __pthread_cleanup_push_imp(cleanup_rout= ine, cleanup_arg,\ > > 174 &__cleanup_info__); = \ > > 175 { > > 176=20 > > 177 #define pthread_cleanup_pop(execute) = \ > > 178 } = \ > > 179 __pthread_cleanup_pop_imp(execute); = \ > > 180 } > > > > > > This patch fixes the problem for me: >=20 > I was hurry when said that the patch fixed the problem. The application > compiled but later it crashed in pthread_cleanup_pop: >=20 > (gdb) bt > #0 0xbf4f9ee0 in ?? () > #1 0x287d18c9 in __pthread_cleanup_pop_imp () from /lib/libthr.so.3 > #2 0x287d18ed in pthread_cleanup_pop () from /lib/libthr.so.3 > #3 0x287d123c in pthread_exit () from /lib/libthr.so.3 > #4 0x287c7757 in pthread_getprio () from /lib/libthr.so.3 > #5 0x00000000 in ?? () >=20 > So, I don't know what these macros actually were supposed to be. They were > introduced in r179662: >=20 > Revision 1.43: download - view: text, markup, annotated - select for diffs > Mon Jun 9 01:14:10 2008 UTC (17 months, 2 weeks ago) by davidxu > Branches: MAIN > Diff to: previous 1.42: preferred, colored > Changes since revision 1.42: +21 -2 lines >=20 > SVN rev 179662 on 2008-06-09 01:14:10Z by davidxu >=20 > Make pthread_cleanup_push() and pthread_cleanup_pop() as a pair of macros, > use stack space to keep cleanup information, this eliminates overhead of > calling malloc() and free() in thread library. >=20 > Discussed on: thread@ >=20 > > --- pthread.h.orig 2009-11-24 16:44:13.000000000 +0200 > > +++ pthread.h 2009-11-24 16:44:45.000000000 +0200 > > @@ -172,10 +172,10 @@ > > struct _pthread_cleanup_info __cleanup_info__; = \ > > __pthread_cleanup_push_imp(cleanup_routine, cle= anup_arg,\ > > &__cleanup_info__); = \ > > - { > > + } =20 > > =20 > > #define pthread_cleanup_pop(execute) = \ > > - } = \ > > + { = \ > > __pthread_cleanup_pop_imp(execute); = \ > > } pthread_cleanup_push/pop are supposed to be used from the common lexical scope. Citation from SUSv4: These functions may be implemented as macros. The application shall ensure that they appear as statements, and in pairs within the same lexical scope (that is, the pthread_cleanup_push() macro may be thought to expand to a token list whose first token is '{' with pthread_cleanup_pop() expanding to a token list whose last token is the corresponding '}' ). Your change is wrong. Basically, the code should do pthread_cleanup_push(some_func, arh); something ... pthread_cleanup_pop(1); (1 denotes that some_func should be called). --i616tqyc3hrkKsk2 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAksL/P4ACgkQC3+MBN1Mb4h4UwCgxIIHVqHBqU9wPIQKiOWf9g2z r94AoOiN4CE6Eig6AlJ1IuHFo9Hk7Pvf =FjUi -----END PGP SIGNATURE----- --i616tqyc3hrkKsk2--