DRD: Suppress uninteresting races triggered by the dynamic loader
authorbart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Wed, 14 Dec 2011 20:05:51 +0000 (20:05 +0000)
committerbart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Wed, 14 Dec 2011 20:05:51 +0000 (20:05 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12308 a5019735-40e9-0310-863c-91ae7b9d1cf9

drd/drd_main.c

index a967a95117b9d3dbe3f656bd6261819e470e4029..3aa308718b93f8fa42963fc9db6bca206e99dd2e 100644 (file)
@@ -324,7 +324,20 @@ void drd_start_using_mem(const Addr a1, const SizeT len,
       DRD_(trace_mem_access)(a1, len, eStart, 0, 0);
    }
 
-   if (UNLIKELY(DRD_(running_thread_inside_pthread_create)()))
+   /*
+    * Hack: telling the tool about initial permissions happens before
+    * the pre_thread_first_insn callback is invoked, which sets
+    * DRD_(g_drd_running_tid). Suppress all memory accesses on these
+    * initial memory regions since sporadically it happens that an
+    * (uninteresting) data race is reported on one of these regions, triggered
+    * by the symbol lookup algorithms in the dynamic loader. That behavior
+    * can be reproduced on Linux/amd64 by disabling the DRD_(g_drd_running_tid)
+    * test below and by running the following command:
+    * ./vg-in-place --tool=drd --check-stack-var=yes \
+    * drd/tests/annotate_smart_pointer 50 50
+    */
+   if (UNLIKELY(DRD_(running_thread_inside_pthread_create)()
+                || DRD_(g_drd_running_tid) == DRD_INVALID_THREADID))
    {
       DRD_(start_suppression)(a1, a2, "pthread_create()");
    }