]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Changed the way how data races in NPTL's thread-private data on the top of the stack...
authorBart Van Assche <bvanassche@acm.org>
Fri, 4 Apr 2008 16:54:37 +0000 (16:54 +0000)
committerBart Van Assche <bvanassche@acm.org>
Fri, 4 Apr 2008 16:54:37 +0000 (16:54 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7841

exp-drd/drd_clientreq.c
exp-drd/drd_thread.c

index 839b3f7efac015a2c0634f432a0ec6526dbbbd90..e8c19d19455a4a9835f59067fcfcad4ff2ec6c7e 100644 (file)
@@ -79,6 +79,24 @@ static void drd_pre_cond_broadcast(const Addr cond)
   cond_pre_broadcast(cond);
 }
 
+/** Walk the stack up to the highest stack frame, and return the stack pointer
+ *  of the highest stack frame. It is assumed that there are no more than
+ *  ten stack frames above the current frame. This should be no problem
+ *  since this function is either called indirectly from the _init() function
+ *  in vgpreload_exp-drd-*.so or from the thread wrapper for a newly created
+ *  thread. See also drd_pthread_intercepts.c.
+ */
+static Addr highest_used_stack_address(const ThreadId vg_tid)
+{
+    UInt nframes;
+    const UInt n_ips = 10;
+    Addr ips[n_ips], sps[n_ips];
+
+    nframes = VG_(get_StackTrace)(vg_tid, ips, n_ips, sps, 0, 0);
+
+    return (nframes >= 1 ? sps[nframes - 1] : VG_(get_SP)(vg_tid));
+}
+
 static Bool drd_handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret)
 {
   UWord result = 0;
@@ -102,8 +120,13 @@ static Bool drd_handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret)
     break;
 
   case VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK:
+  {
+    const Addr topmost_sp = highest_used_stack_address(vg_tid);
     thread_set_stack_startup(drd_tid, VG_(get_SP)(vg_tid));
+    drd_start_suppression(topmost_sp, VG_(thread_get_stack_max)(vg_tid),
+                          "stack top");
     break;
+  }
 
   case VG_USERREQ__DRD_START_NEW_SEGMENT:
     thread_new_segment(PtThreadIdToDrdThreadId(arg[1]));
index b8eb755ad0436e77e7cce4172eb0955716ad855a..2a31856aa55225321252bbeb1b1703f99023df6e 100644 (file)
@@ -905,26 +905,6 @@ static void thread_update_danger_set(const DrdThreadId tid)
           }
       }
     }
-
-    for (j = 0; j < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); j++)
-    {
-      if (IsValidDrdThreadId(j))
-      {
-        // NPTL hack: don't report data races on sizeof(struct pthread)
-        // bytes at the top of the stack, since the NPTL functions access
-        // this data without locking.
-        if (s_threadinfo[j].stack_min != 0)
-        {
-          tl_assert(s_threadinfo[j].stack_startup != 0);
-          if (s_threadinfo[j].stack_min < s_threadinfo[j].stack_startup)
-          {
-            bm_clear(s_danger_set,
-                     s_threadinfo[j].stack_min,
-                     s_threadinfo[j].stack_startup);
-          }
-        }
-      }
-    }
   }
 
   s_danger_set_bitmap_creation_count  += bm_get_bitmap_creation_count();