diff options
author | Doug Rabson <dfr@FreeBSD.org> | 2000-07-21 09:31:13 +0000 |
---|---|---|
committer | Doug Rabson <dfr@FreeBSD.org> | 2000-07-21 09:31:13 +0000 |
commit | 678ef1b49eb8de71bea62013193bb8f49c5e3811 (patch) | |
tree | c00a90e2c23aaa9a9e6f0166e6de86233a9b3d5e /lib | |
parent | a606bbf4c867581b350d9e06b25d78b9177911a4 (diff) | |
download | src-678ef1b49eb8de71bea62013193bb8f49c5e3811.tar.gz src-678ef1b49eb8de71bea62013193bb8f49c5e3811.zip |
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
Notes
Notes:
svn path=/head/; revision=63710
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc_r/uthread/uthread_once.c | 2 | ||||
-rw-r--r-- | lib/libkse/thread/thr_once.c | 2 | ||||
-rw-r--r-- | lib/libpthread/thread/thr_once.c | 2 |
3 files changed, 6 insertions, 0 deletions
diff --git a/lib/libc_r/uthread/uthread_once.c b/lib/libc_r/uthread/uthread_once.c index ea56d82c4d83..d7bb494b6741 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(); diff --git a/lib/libkse/thread/thr_once.c b/lib/libkse/thread/thr_once.c index ea56d82c4d83..d7bb494b6741 100644 --- a/lib/libkse/thread/thr_once.c +++ b/lib/libkse/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(); diff --git a/lib/libpthread/thread/thr_once.c b/lib/libpthread/thread/thr_once.c index ea56d82c4d83..d7bb494b6741 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(); |