|
From: <sv...@va...> - 2011-03-08 18:34:52
|
Author: bart
Date: 2011-03-08 18:34:44 +0000 (Tue, 08 Mar 2011)
New Revision: 11612
Log:
DRD: Fixed a race condition triggered by invoking pthread_detach() with an argument not equal to pthread_self(). Potential fix for #267968.
Modified:
trunk/drd/drd_pthread_intercepts.c
Modified: trunk/drd/drd_pthread_intercepts.c
===================================================================
--- trunk/drd/drd_pthread_intercepts.c 2011-03-08 18:32:36 UTC (rev 11611)
+++ trunk/drd/drd_pthread_intercepts.c 2011-03-08 18:34:44 UTC (rev 11612)
@@ -269,7 +269,6 @@
arg_ptr = (DrdPosixThreadArgs*)arg;
arg_copy = *arg_ptr;
- arg_ptr->wrapper_started = 1;
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SET_PTHREADID,
pthread_self(), 0, 0, 0, 0);
@@ -277,6 +276,13 @@
DRD_(set_joinable)(pthread_self(),
arg_copy.detachstate == PTHREAD_CREATE_JOINABLE);
+ /*
+ * Only set 'wrapper_started' after VG_USERREQ__SET_PTHREADID and
+ * DRD_(set_joinable)() have been invoked to avoid a race with
+ * a pthread_detach() invocation for this thread from another thread.
+ */
+ arg_ptr->wrapper_started = 1;
+
return (arg_copy.start)(arg_copy.arg);
}
|