From: Bart Van Assche Date: Wed, 9 Feb 2011 11:55:12 +0000 (+0000) Subject: DRD: handle fork() in processes with detached threads correctly (see also #255355). X-Git-Tag: svn/VALGRIND_3_7_0~672 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2ca0b1b5d1c0a3e06e1ac1fc8d25760f58a31992;p=thirdparty%2Fvalgrind.git DRD: handle fork() in processes with detached threads correctly (see also #255355). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11532 --- diff --git a/drd/drd_thread.c b/drd/drd_thread.c index f85a5b0923..a31531ed9d 100644 --- a/drd/drd_thread.c +++ b/drd/drd_thread.c @@ -367,7 +367,7 @@ void DRD_(thread_post_join)(DrdThreadId drd_joiner, DrdThreadId drd_joinee) DRD_(thread_get_stack_max)(drd_joinee)); } DRD_(clientobj_delete_thread)(drd_joinee); - DRD_(thread_delete)(drd_joinee); + DRD_(thread_delete)(drd_joinee, False); } /** @@ -450,7 +450,7 @@ Int DRD_(thread_get_threads_on_alt_stack)(void) * Clean up thread-specific data structures. Call this just after * pthread_join(). */ -void DRD_(thread_delete)(const DrdThreadId tid) +void DRD_(thread_delete)(const DrdThreadId tid, const Bool detached) { Segment* sg; Segment* sg_prev; @@ -467,7 +467,10 @@ void DRD_(thread_delete)(const DrdThreadId tid) } DRD_(g_threadinfo)[tid].vg_thread_exists = False; DRD_(g_threadinfo)[tid].posix_thread_exists = False; - tl_assert(DRD_(g_threadinfo)[tid].detached_posix_thread == False); + if (detached) + DRD_(g_threadinfo)[tid].detached_posix_thread = False; + else + tl_assert(!DRD_(g_threadinfo)[tid].detached_posix_thread); DRD_(g_threadinfo)[tid].first = 0; DRD_(g_threadinfo)[tid].last = 0; @@ -514,7 +517,7 @@ void DRD_(drd_thread_atfork_child)(const DrdThreadId tid) if (i == tid) continue; if (DRD_(IsValidDrdThreadId(i))) - DRD_(thread_delete)(i); + DRD_(thread_delete)(i, True); tl_assert(!DRD_(IsValidDrdThreadId(i))); } } diff --git a/drd/drd_thread.h b/drd/drd_thread.h index 920df4a28c..8d63467acf 100644 --- a/drd/drd_thread.h +++ b/drd/drd_thread.h @@ -134,7 +134,7 @@ DrdThreadId DRD_(thread_pre_create)(const DrdThreadId creator, const ThreadId vg_created); DrdThreadId DRD_(thread_post_create)(const ThreadId vg_created); void DRD_(thread_post_join)(DrdThreadId drd_joiner, DrdThreadId drd_joinee); -void DRD_(thread_delete)(const DrdThreadId tid); +void DRD_(thread_delete)(const DrdThreadId tid, Bool detached); void DRD_(thread_finished)(const DrdThreadId tid); void DRD_(drd_thread_atfork_child)(const DrdThreadId tid); void DRD_(thread_pre_cancel)(const DrdThreadId tid);