Skip to content

Commit

Permalink
Move call to _malloc_thread_cleanup() so that if this is the last thr…
Browse files Browse the repository at this point in the history
…ead,

the call never happens.  This is necessary because malloc may be used
during exit handler processing.

Submitted by:	davidxu
  • Loading branch information
jasone committed Sep 9, 2008
1 parent b96d99d commit c30fff5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/libthr/thread/thr_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down

0 comments on commit c30fff5

Please sign in to comment.