From c30fff54190f893ece2e107d0412e0cf782f47fc Mon Sep 17 00:00:00 2001 From: jasone Date: Tue, 9 Sep 2008 17:14:32 +0000 Subject: [PATCH] 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 --- lib/libthr/thread/thr_exit.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c index 4e14311a7df3..33a2451a45ae 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) {