summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2007-11-06 21:50:43 +0000
committermarius <marius@FreeBSD.org>2007-11-06 21:50:43 +0000
commitaf79ab51ec50700670b4f534afe2b40e4ed05a57 (patch)
tree67875d8c228cb7d69e0b0efa33ea6b2dae9071ff /lib/libthr
parent80e691eb7fe6da094ac1cc2f552ad92046f1a847 (diff)
downloadFreeBSD-src-af79ab51ec50700670b4f534afe2b40e4ed05a57.zip
FreeBSD-src-af79ab51ec50700670b4f534afe2b40e4ed05a57.tar.gz
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
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_spec.c6
1 files changed, 5 insertions, 1 deletions
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++) {
OpenPOWER on IntegriCloud