Replaced code for suppressing the stack memory in use at the time a
thread is being created by code for suppressing the memory allocated
from inside the pthread_create() call. The new implementation should be
a more portable solution for suppressing data races triggered by the
thread-local-storage implementation of a Pthreads library.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10584 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/drd/drd_thread.c b/drd/drd_thread.c
index 04ec912..528b7b3 100644
--- a/drd/drd_thread.c
+++ b/drd/drd_thread.c
@@ -184,6 +184,7 @@
DRD_(thread_set_name)(i, "");
DRD_(g_threadinfo)[i].is_recording_loads = True;
DRD_(g_threadinfo)[i].is_recording_stores = True;
+ DRD_(g_threadinfo)[i].pthread_create_nesting_level = 0;
DRD_(g_threadinfo)[i].synchr_nesting = 0;
tl_assert(DRD_(g_threadinfo)[i].first == 0);
tl_assert(DRD_(g_threadinfo)[i].last == 0);
@@ -520,6 +521,28 @@
DRD_(g_threadinfo)[tid].detached_posix_thread = ! joinable;
}
+/** Tells DRD that the calling thread is about to enter pthread_create(). */
+void DRD_(thread_entering_pthread_create)(const DrdThreadId tid)
+{
+ tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
+ && tid != DRD_INVALID_THREADID);
+ tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID);
+ tl_assert(DRD_(g_threadinfo)[tid].pthread_create_nesting_level >= 0);
+
+ DRD_(g_threadinfo)[tid].pthread_create_nesting_level++;
+}
+
+/** Tells DRD that the calling thread has left pthread_create(). */
+void DRD_(thread_left_pthread_create)(const DrdThreadId tid)
+{
+ tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
+ && tid != DRD_INVALID_THREADID);
+ tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID);
+ tl_assert(DRD_(g_threadinfo)[tid].pthread_create_nesting_level > 0);
+
+ DRD_(g_threadinfo)[tid].pthread_create_nesting_level--;
+}
+
/** Obtain the thread number and the user-assigned thread name. */
const char* DRD_(thread_get_name)(const DrdThreadId tid)
{