From owner-freebsd-threads@FreeBSD.ORG Wed Dec 21 19:28:59 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 EB7C9106566C for ; Wed, 21 Dec 2011 19:28:59 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id A21338FC18 for ; Wed, 21 Dec 2011 19:28:59 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id pBLJSwCc003062; Wed, 21 Dec 2011 14:28:58 -0500 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Wed, 21 Dec 2011 14:28:58 -0500 (EST) Date: Wed, 21 Dec 2011 14:28:58 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Steven Wills In-Reply-To: <201112211900.pBLJ0Cr0034356@red.freebsd.org> Message-ID: References: <201112211900.pBLJ0Cr0034356@red.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-gnats-submit@freebsd.org, freebsd-threads@freebsd.org Subject: Re: threads/163512: libc defaults to single threaded X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Dec 2011 19:29:00 -0000 >> Description: > 1) libc defaults to being single-threaded > 2) thus apps not linked against libthr don't initialize the structures that threading depends on > 3) this causes bugs when said app loads a library that loads libthr > 4) said library will take the threaded code path and reference uninitialized data structures > > An example of this can be seen by removing ports/devel/p5-Glib2/files/patch-threadstest then after building, run "make test" from work/Glib-1.241. Perl will hang in state umtxn. > > I believe this may also be the source of an intermittent hang in automoc4 (also stuck in state umtxn) seen while building x11/kde4. This was discussed here: > > http://mail.kde.org/pipermail/kde-freebsd/2011-November/012211.html > https://bugs.kde.org/show_bug.cgi?id=276461 This has always been the case. If an application is going to be linked to a library that requires threads, then that application has to link to libpthread. Applications should be built knowing whether libpthread will be required or not. Either that, or the library should be built to detect whether threading is present and only use thrading features when threading is present (see how libgcc does this as example). The former or latter depends on the what the library is trying to provide. If it needs to spawn threads to accomplish its job, then the former (application needs to link with libpthread). If the library just needs synchronization primitives to protect against a threaded application, then you can use the latter. If the application is kinda stupid and really doesn't know if threads are required, then there probably is no harm in always linking to libpthread. -- DE