From 92f8396b0c8e4f146563b87f46137484cfb36e31 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 11 Jul 2012 23:36:46 -0400 Subject: fix potential race condition in detached threads after the thread unmaps its own stack/thread structure, the kernel, performing child tid clear and futex wake, could clobber a new mapping made at the same location as the just-removed thread's tid field. disable kernel clearing of child tid to prevent this. --- src/thread/pthread_detach.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/thread/pthread_detach.c') diff --git a/src/thread/pthread_detach.c b/src/thread/pthread_detach.c index 8ef03d51..e8032398 100644 --- a/src/thread/pthread_detach.c +++ b/src/thread/pthread_detach.c @@ -5,7 +5,7 @@ int pthread_detach(pthread_t t) /* Cannot detach a thread that's already exiting */ if (a_swap(&t->exitlock, 1)) return pthread_join(t, 0); - t->detached = 1; - t->exitlock = 0; + t->detached = 2; + a_store(&t->exitlock, 0); return 0; } -- cgit v1.2.1