Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Dec 2011 20:10:13 GMT
From:      Daniel Eischen <deischen@freebsd.org>
To:        freebsd-threads@FreeBSD.org
Subject:   Re: threads/163512: libc defaults to single threaded 
Message-ID:  <201112212010.pBLKAD46064847@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR threads/163512; it has been noted by GNATS.

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 
Date: Wed, 21 Dec 2011 14:28:58 -0500 (EST)

 >> 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?201112212010.pBLKAD46064847>