summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2004-10-06 14:23:00 +0000
committermtm <mtm@FreeBSD.org>2004-10-06 14:23:00 +0000
commit0a21f474dc2916335177c20f10de96a7a093926e (patch)
tree3804089a0d0cecc531066dc2a0a074eddea8153b /lib/libthr
parent66f574f53756cb0fd20f1dd2790d90850ef49f3c (diff)
downloadFreeBSD-src-0a21f474dc2916335177c20f10de96a7a093926e.zip
FreeBSD-src-0a21f474dc2916335177c20f10de96a7a093926e.tar.gz
Close a race between a thread exiting and the freeing of it's stack.
After some discussion the best option seems to be to signal the thread's death from within the kernel. This requires that thr_exit() take an argument. Discussed with: davidxu, deischen, marcel MFC after: 3 days
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_exit.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c
index f71c59a..3ee5fa5 100644
--- a/lib/libthr/thread/thr_exit.c
+++ b/lib/libthr/thread/thr_exit.c
@@ -43,7 +43,7 @@
__weak_reference(_pthread_exit, pthread_exit);
/* thr_exit() */
-extern int _thr_exit(void);
+extern int _thr_exit(long *state);
static void deadlist_free_threads();
@@ -164,7 +164,6 @@ _pthread_exit(void *status)
deadlist_free_threads();
TAILQ_INSERT_HEAD(&_dead_list, curthread, dle);
TAILQ_REMOVE(&_thread_list, curthread, tle);
- curthread->isdead = 1;
/* If we're the last thread, call it quits */
if (TAILQ_EMPTY(&_thread_list))
@@ -181,7 +180,7 @@ _pthread_exit(void *status)
* thread, which we can't be because we've already checked
* for that.
*/
- _thr_exit();
+ _thr_exit((long *)&curthread->isdead);
/* This point should not be reached. */
PANIC("Dead thread has resumed");
OpenPOWER on IntegriCloud