From ce193bdc46e79c71e7c9070a71fe8317ed3dfbaa Mon Sep 17 00:00:00 2001 From: mtm Date: Wed, 13 Oct 2004 11:42:20 +0000 Subject: 1. Now that it's a thread's state is changed from within the kernel, where no userland locks are heald, the dead thread lock can no longer protect access to it. Therefore, instead of using an if (!dead)...else clause after walking the active threads list test the thread pointer before deciding not to walk the dead threads list. If the thread pointer is null it means it was not found in the active threads list and the dead threads list should be checked. 2. Do not free the stack of a thread that is not marked dead. This is the 2nd and final part of eliminating the race to free a thread's stack. MFC after: 3 days --- lib/libthr/thread/thr_exit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/libthr/thread/thr_exit.c') diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c index 6a45687..f74b5e1 100644 --- a/lib/libthr/thread/thr_exit.c +++ b/lib/libthr/thread/thr_exit.c @@ -195,7 +195,8 @@ deadlist_free_threads() TAILQ_FOREACH_SAFE(ptd, &_dead_list, dle, ptdTemp) { /* Don't destroy the initial thread or non-detached threads. */ if (ptd == _thread_initial || - (ptd->attr.flags & PTHREAD_DETACHED) == 0) + (ptd->attr.flags & PTHREAD_DETACHED) == 0 || + !ptd->isdead) continue; TAILQ_REMOVE(&_dead_list, ptd, dle); deadlist_free_onethread(ptd); -- cgit v1.1