summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2008-09-09 17:14:32 +0000
committerjasone <jasone@FreeBSD.org>2008-09-09 17:14:32 +0000
commitc30fff54190f893ece2e107d0412e0cf782f47fc (patch)
tree6ef5e580b31b11654e4ced36d8f0e6a2c0f9e161 /lib/libthr/thread
parentb96d99dacd01873601f7113ed545e1272d1cfa82 (diff)
downloadFreeBSD-src-c30fff54190f893ece2e107d0412e0cf782f47fc.zip
FreeBSD-src-c30fff54190f893ece2e107d0412e0cf782f47fc.tar.gz
Move call to _malloc_thread_cleanup() so that if this is the last thread,
the call never happens. This is necessary because malloc may be used during exit handler processing. Submitted by: davidxu
Diffstat (limited to 'lib/libthr/thread')
-rw-r--r--lib/libthr/thread/thr_exit.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c
index 4e14311..33a2451 100644
--- a/lib/libthr/thread/thr_exit.c
+++ b/lib/libthr/thread/thr_exit.c
@@ -96,9 +96,6 @@ _pthread_exit(void *status)
_thread_cleanupspecific();
}
- /* Tell malloc that the thread is exiting. */
- _malloc_thread_cleanup();
-
if (!_thr_isthreaded())
exit(0);
@@ -109,6 +106,12 @@ _pthread_exit(void *status)
exit(0);
/* Never reach! */
}
+ THREAD_LIST_UNLOCK(curthread);
+
+ /* Tell malloc that the thread is exiting. */
+ _malloc_thread_cleanup();
+
+ THREAD_LIST_LOCK(curthread);
THR_LOCK(curthread);
curthread->state = PS_DEAD;
if (curthread->flags & THR_FLAGS_NEED_SUSPEND) {
OpenPOWER on IntegriCloud