diff options
author | dfr <dfr@FreeBSD.org> | 2000-07-21 09:31:13 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 2000-07-21 09:31:13 +0000 |
commit | a8bebf2b2d07d6e1bbd97ab413d1b435e0784aec (patch) | |
tree | d101fed38ff24e3ef38cdcae7405afffea969965 /lib/libc_r | |
parent | 169165247865d7299941f6117f31ad5277e652be (diff) | |
download | FreeBSD-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/libc_r')
-rw-r--r-- | lib/libc_r/uthread/uthread_once.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libc_r/uthread/uthread_once.c b/lib/libc_r/uthread/uthread_once.c index ea56d82..d7bb494 100644 --- a/lib/libc_r/uthread/uthread_once.c +++ b/lib/libc_r/uthread/uthread_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(); |