Author: sewardj
Date: 2007-12-01 02:09:50 +0000 (Sat, 01 Dec 2007)
New Revision: 7261

Log:
Only pass valid ThreadIDs to VG_(record_ExeContext).  (Bart Van Assche)

Modified:
   trunk/exp-drd/TODO.txt
   trunk/exp-drd/drd_preloaded.c
   trunk/exp-drd/drd_segment.c


Modified: trunk/exp-drd/TODO.txt
===================================================================
--- trunk/exp-drd/TODO.txt      2007-11-30 21:52:27 UTC (rev 7260)
+++ trunk/exp-drd/TODO.txt      2007-12-01 02:09:50 UTC (rev 7261)
@@ -4,6 +4,7 @@
 
 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&)

Modified: trunk/exp-drd/drd_preloaded.c
===================================================================
--- trunk/exp-drd/drd_preloaded.c       2007-11-30 21:52:27 UTC (rev 7260)
+++ trunk/exp-drd/drd_preloaded.c       2007-12-01 02:09:50 UTC (rev 7261)
@@ -198,10 +198,6 @@
       {
          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 @@
    // 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;

Modified: trunk/exp-drd/drd_segment.c
===================================================================
--- trunk/exp-drd/drd_segment.c 2007-11-30 21:52:27 UTC (rev 7260)
+++ trunk/exp-drd/drd_segment.c 2007-12-01 02:09:50 UTC (rev 7261)
@@ -23,15 +23,16 @@
 */
 
 
+#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 @@
              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 @@
   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);


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to