summaryrefslogtreecommitdiffstats
path: root/lib/libpthread
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>2000-07-21 09:31:13 +0000
committerdfr <dfr@FreeBSD.org>2000-07-21 09:31:13 +0000
commita8bebf2b2d07d6e1bbd97ab413d1b435e0784aec (patch)
treed101fed38ff24e3ef38cdcae7405afffea969965 /lib/libpthread
parent169165247865d7299941f6117f31ad5277e652be (diff)
downloadFreeBSD-src-a8bebf2b2d07d6e1bbd97ab413d1b435e0784aec.zip
FreeBSD-src-a8bebf2b2d07d6e1bbd97ab413d1b435e0784aec.tar.gz
Call _thread_init() from pthread_once() if it has not already been called.
This fixes a segfault in some C++ programs which use exceptions before main() has been called (i.e. from global constructors). Reviewed by: deischen
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/thread/thr_once.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libpthread/thread/thr_once.c b/lib/libpthread/thread/thr_once.c
index ea56d82..d7bb494 100644
--- a/lib/libpthread/thread/thr_once.c
+++ b/lib/libpthread/thread/thr_once.c
@@ -39,6 +39,8 @@ int
pthread_once(pthread_once_t * once_control, void (*init_routine) (void))
{
if (once_control->state == PTHREAD_NEEDS_INIT) {
+ if (_thread_initial == NULL)
+ _thread_init();
pthread_mutex_lock(&(once_control->mutex));
if (once_control->state == PTHREAD_NEEDS_INIT) {
init_routine();
OpenPOWER on IntegriCloud