From af79ab51ec50700670b4f534afe2b40e4ed05a57 Mon Sep 17 00:00:00 2001 From: marius Date: Tue, 6 Nov 2007 21:50:43 +0000 Subject: In _pthread_key_create() ensure that libthr is initialized. This fixes a NULL-dereference of curthread when libstdc+ initializes the exception handling globals on archs we can't use GNU TLS due to lack of support in binutils 2.15 (i.e. arm and sparc64), yet, thus making threaded C++ programs compiled with GCC 4.2.1 work again on these archs. Reviewed by: davidxu MFC after: 3 days --- lib/libthr/thread/thr_spec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/libthr') diff --git a/lib/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c index 36e74f2..06d1287 100644 --- a/lib/libthr/thread/thr_spec.c +++ b/lib/libthr/thread/thr_spec.c @@ -51,9 +51,13 @@ __weak_reference(_pthread_setspecific, pthread_setspecific); int _pthread_key_create(pthread_key_t *key, void (*destructor) (void *)) { - struct pthread *curthread = _get_curthread(); + struct pthread *curthread; int i; + _thr_check_init(); + + curthread = _get_curthread(); + /* Lock the key table: */ THR_LOCK_ACQUIRE(curthread, &_keytable_lock); for (i = 0; i < PTHREAD_KEYS_MAX; i++) { -- cgit v1.1