Date: Wed, 21 Dec 2011 14:28:58 -0500 (EST) From: Daniel Eischen <deischen@freebsd.org> To: Steven Wills <swills@freebsd.org> Cc: freebsd-gnats-submit@freebsd.org, freebsd-threads@freebsd.org Subject: Re: threads/163512: libc defaults to single threaded Message-ID: <Pine.GSO.4.64.1112211418100.4729@sea.ntplx.net> In-Reply-To: <201112211900.pBLJ0Cr0034356@red.freebsd.org> References: <201112211900.pBLJ0Cr0034356@red.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.1112211418100.4729>