From owner-freebsd-threads@FreeBSD.ORG Fri Nov 27 22:11:00 2009 Return-Path: Delivered-To: threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 142D6106566C for ; Fri, 27 Nov 2009 22:11:00 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from creme-brulee.marcuscom.com (marcuscom-pt.tunnel.tserv1.fmt.ipv6.he.net [IPv6:2001:470:1f00:ffff::1279]) by mx1.freebsd.org (Postfix) with ESMTP id BCE6E8FC0A for ; Fri, 27 Nov 2009 22:10:59 +0000 (UTC) Received: from [IPv6:2001:470:1f00:2464::4] (shumai.marcuscom.com [IPv6:2001:470:1f00:2464::4]) by creme-brulee.marcuscom.com (8.14.3/8.14.3) with ESMTP id nARMDANx072093; Fri, 27 Nov 2009 17:13:10 -0500 (EST) (envelope-from marcus@FreeBSD.org) From: Joe Marcus Clarke To: Kostik Belousov In-Reply-To: <20091127220706.GJ2368@deviant.kiev.zoral.com.ua> References: <1259298918.1608.19.camel@shumai.marcuscom.com> <20091127131242.GA2368@deviant.kiev.zoral.com.ua> <1259349248.1608.36.camel@shumai.marcuscom.com> <4AF1E295-0524-4C39-94CD-9A12D574C64D@vigrid.com> <20091127213046.GI2368@deviant.kiev.zoral.com.ua> <1259358800.1608.46.camel@shumai.marcuscom.com> <20091127220706.GJ2368@deviant.kiev.zoral.com.ua> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-DYKfFuZ9SjIvjz9I/gAv" Organization: FreeBSD, Inc. Date: Fri, 27 Nov 2009 17:11:13 -0500 Message-Id: <1259359873.1608.48.camel@shumai.marcuscom.com> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 FreeBSD GNOME Team Port X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,MIME_QP_LONG_LINE, NO_RELAYS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on creme-brulee.marcuscom.com Cc: "threads@freebsd.org" Subject: Re: [PATCH] Add missing pthread_condattr_{init,destroy} stubs to libc 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: Fri, 27 Nov 2009 22:11:00 -0000 --=-DYKfFuZ9SjIvjz9I/gAv Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sat, 2009-11-28 at 00:07 +0200, Kostik Belousov wrote: > On Fri, Nov 27, 2009 at 04:53:20PM -0500, Joe Marcus Clarke wrote: > > On Fri, 2009-11-27 at 23:30 +0200, Kostik Belousov wrote: > > > On Fri, Nov 27, 2009 at 04:19:38PM -0500, Daniel Eischen wrote: > > > >=20 > > > > On Nov 27, 2009, at 2:14 PM, Joe Marcus Clarke = =20 > > > > wrote: > > > >=20 > > > > >On Fri, 2009-11-27 at 15:12 +0200, Kostik Belousov wrote: > > > > >>On Fri, Nov 27, 2009 at 12:15:18AM -0500, Joe Marcus Clarke wrote= : > > > > >>>I would like permission to commit this patch which adds missing > > > > >>>pthread_condattr_{init,destroy} symbols to libc. I think I did = the > > > > >>>symbol addition correctly (and it seems to work). Without this,= the > > > > >>>weak symbols added in the libpthread-stubs port conflict with =20 > > > > >>>those in > > > > >>>libthr, and applications with use these symbols can crash. > > > > >>> > > > > >>>I have temporarily hacked libpthread-stubs to fix this, but I re= ally > > > > >>>feel these stubs should be added to libc. I've also copied kib = as =20 > > > > >>>he > > > > >>>has been kind enough to review my work in the past. Thanks. > > > > >>> > > > > >>>http://www.marcuscom.com/downloads/stubs.diff > > > > >> > > > > >>It is FBSD_1.2 version that we use for symbols added after HEAD =20 > > > > >>become > > > > >>CURRENT-9. > > > > > > > > > >Done. > > > >=20 > > > > I don't think the symbols belong in FBSD_1.2. They already exist i= n =20 > > > > libthr in a previous namespace. If you use FBSD_1.2, then you =20 > > > > probably need to bump them in libthr and libc_r, and add compatible= =20 > > > > symbols (no problem there since there are no differences) for the =20 > > > > previous versions. > > > Oh, yes. > > >=20 > > > >=20 > > > > Still not sure why libc needs all libpthread stubs. Shouldn't be =20 > > > > necessary. > > >=20 > > > The privately discussed plan for 9.0 is to have libthr merged into > > > libc, and have libpthread and libthr as only filter object against li= bc > > > providing pthread_* and related symbols. > > >=20 > > > This would eliminate the need for pthread stubs and solve the issues > > > with (wrongly built) binaries that do not link to libthr but dlopen() > > > libraries that are linked with it. > >=20 > > Yeah, I think that would be a great overall solution. However, in this > > case, the binaries in question ARE linked with -pthread. The problem > > can be easily seen by taking this C program: > >=20 > > #include > > #include > > #include > >=20 > > int > > main(void) { > > pthread_condattr_t attr; > >=20 > > pthread_condattr_init (&attr); > > pthread_condattr_setclock (&attr, CLOCK_MONOTONIC); > >=20 > > pthread_condattr_destroy (&attr); > >=20 > > return 0; > > } > >=20 > > And compiling it as: > >=20 > > cc -o xxx -L/usr/local/lib -lpthread-stubs -pthread xxx.c > >=20 > > You will need devel/libpthread-stubs (version 0.3) installed. When you > > run it, it will segfault. If you then rebuild libc and libthr with my > > stubs.diff patch, then rebuild libpthread-stubs, the problem will go > > away. >=20 > I see. What happen there is that both libpthread-stubs and libthr > provide _weak_ symbols pthread_condattr_destroy and pthread_condattr_init= . > Actually, these two symbols are the only exported symbols from stubs > library. Due to specified library order, rtld for xxx resolves these > symbols from stubs, not from libthr. But pthread_condattr_setclock > is only exported weak from libthr, and it gets used. >=20 > This ends up supplying initialized attributes to pthread_condattr_setcloc= k. >=20 > Your patch makes libc provide these two weak symbols, and then > stubs seems to become empty library. 100% correct all around. In fact, if you read the manifesto for libpthread-stubs, it is designed to be an empty library on systems which provide all of the necessary stubs. In that case, it just provides its pkg-config file. I didn't see a better way of fixing this. I'm still fuzzy on how to do the correct symbol map dance for libthr/libc_r. Do you know of any example symbols which had to be updated in this fashion? Joe --=20 Joe Marcus Clarke FreeBSD GNOME Team :: gnome@FreeBSD.org FreeNode / #freebsd-gnome http://www.FreeBSD.org/gnome --=-DYKfFuZ9SjIvjz9I/gAv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEABECAAYFAksQTn8ACgkQb2iPiv4Uz4fbOACfYYlbLQvcMJAYVq8YvfWAKSv0 9EYAn1vDNuOZLr7ytI68Hg6k+j0nzk02 =cwF7 -----END PGP SIGNATURE----- --=-DYKfFuZ9SjIvjz9I/gAv--