]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Only pass valid ThreadIDs to VG_(record_ExeContext). (Bart Van Assche)
authorJulian Seward <jseward@acm.org>
Sat, 1 Dec 2007 02:09:50 +0000 (02:09 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 1 Dec 2007 02:09:50 +0000 (02:09 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7261

exp-drd/TODO.txt
exp-drd/drd_preloaded.c
exp-drd/drd_segment.c

index cbe891f33d627d0fbc4c3f3a32e63824cec40bb2..3566e8c6c64245e80ad72c95eb84a38e48f22a4b 100644 (file)
@@ -4,6 +4,7 @@ Last updated February 22, 2006
 
 Data-race detection algorithm
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- Implement glibc version detection in drd_main.c.
 - Implement segment merging, such that the number of segments per thread
   remains limited even when there is no synchronization between threads.
 - Find out why a race is reported on std::string::string(std::string const&)
index 0a0b30035b403f017d2b5972b31a111a2cb1fce5..a0c6a1a84e8a7dccab8a48ae8adfe0ea8dac4e02 100644 (file)
@@ -198,10 +198,6 @@ PTH_FUNC(int, pthreadZucreateZAZa, // pthread_create@*
       {
          assert(0);
       }
-#if 0
-      printf("[%ld] Requested detach state for new thread: %d\n",
-             pthread_self(), vgargs.detachstate);
-#endif
    }
    assert(vgargs.detachstate == PTHREAD_CREATE_JOINABLE
           || vgargs.detachstate == PTHREAD_CREATE_DETACHED);
@@ -224,9 +220,12 @@ PTH_FUNC(int, pthreadZucreateZAZa, // pthread_create@*
    // in this file (vg_preloaded.c) would be called instead of those in
    // libpthread.so. This loop is necessary because vgargs is allocated on the
    // stack, and the created thread reads it.
-   while (! vgargs.wrapper_started)
+   if (ret == 0)
    {
-      sched_yield();
+      while (! vgargs.wrapper_started)
+      {
+         sched_yield();
+      }
    }
 #endif
    return ret;
index cb4b979ce9b6ceb0fa19741b8fe9af709080f0a6..a83a4148f06d681245b9a578c6a848433f7028e8 100644 (file)
 */
 
 
+#include "drd_error.h"
+#include "drd_segment.h"
+#include "drd_thread.h"
 #include "pub_tool_basics.h"      // Addr, SizeT
 #include "pub_tool_errormgr.h"    // VG_(unique_error)()
 #include "pub_tool_libcassert.h"  // tl_assert()
 #include "pub_tool_libcbase.h"    // VG_(strlen)()
 #include "pub_tool_libcprint.h"   // VG_(printf)()
 #include "pub_tool_mallocfree.h"  // VG_(malloc)(), VG_(free)()
-#include "drd_error.h"
-#include "drd_segment.h"
-#include "drd_thread.h"
+#include "pub_tool_threadstate.h" // VG_INVALID_THREADID
 
 
 // Local variables.
@@ -52,6 +53,7 @@ void sg_init(Segment* const sg,
              DrdThreadId const created)
 {
   Segment* creator_sg;
+  ThreadId vg_created = DrdThreadIdToVgThreadId(created);
 
   tl_assert(sg);
   tl_assert(creator == DRD_INVALID_THREADID || IsValidDrdThreadId(creator));
@@ -62,7 +64,10 @@ void sg_init(Segment* const sg,
   sg->next = 0;
   sg->prev = 0;
 
-  sg->stacktrace = VG_(record_ExeContext)(created, 0);
+  if (vg_created != VG_INVALID_THREADID)
+    sg->stacktrace = VG_(record_ExeContext)(vg_created, 0);
+  else
+    sg->stacktrace = 0;
 
   if (creator_sg)
     vc_copy(&sg->vc, &creator_sg->vc);