[compiler-rt] r177260 - tsan: fix Go build

Dmitry Vyukov dvyukov at google.com
Mon Mar 18 01:52:47 PDT 2013


Author: dvyukov
Date: Mon Mar 18 03:52:46 2013
New Revision: 177260

URL: http://llvm.org/viewvc/llvm-project?rev=177260&view=rev
Log:
tsan: fix Go build

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h
    compiler-rt/trunk/lib/tsan/go/buildgo.sh
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h?rev=177260&r1=177259&r2=177260&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h Mon Mar 18 03:52:46 2013
@@ -34,7 +34,7 @@ enum ThreadStatus {
 class ThreadContextBase {
  public:
   explicit ThreadContextBase(u32 tid);
-  virtual ~ThreadContextBase();
+  ~ThreadContextBase();
 
   const u32 tid;  // Thread ID. Main thread should have tid = 0.
   u64 unique_id;  // Unique thread ID.

Modified: compiler-rt/trunk/lib/tsan/go/buildgo.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/buildgo.sh?rev=177260&r1=177259&r2=177260&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/buildgo.sh (original)
+++ compiler-rt/trunk/lib/tsan/go/buildgo.sh Mon Mar 18 03:52:46 2013
@@ -20,6 +20,7 @@ SRCS="
 	../../sanitizer_common/sanitizer_flags.cc
 	../../sanitizer_common/sanitizer_libc.cc
 	../../sanitizer_common/sanitizer_printf.cc
+	../../sanitizer_common/sanitizer_thread_registry.cc
 "
 
 if [ "`uname -a | grep Linux`" != "" ]; then
@@ -60,7 +61,7 @@ for F in $SRCS; do
 	cat $F >> gotsan.cc
 done
 
-FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -m64 -Wall -Werror -fno-exceptions -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4 $OSCFLAGS"
+FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -m64 -Wall -Werror -fno-exceptions -fno-rtti -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4 $OSCFLAGS"
 if [ "$DEBUG" == "" ]; then
 	FLAGS+=" -DTSAN_DEBUG=0 -O3 -fomit-frame-pointer"
 else

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=177260&r1=177259&r2=177260&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Mon Mar 18 03:52:46 2013
@@ -50,7 +50,6 @@ Context *CTX() {
 static char thread_registry_placeholder[sizeof(ThreadRegistry)];
 
 static ThreadContextBase *CreateThreadContext(u32 tid) {
-  StatInc(cur_thread(), StatThreadMaxTid);
   // Map thread trace when context is created.
   MapThreadTrace(GetThreadTrace(tid), TraceSize() * sizeof(Event));
   void *mem = MmapOrDie(sizeof(ThreadContext), "ThreadContext");

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=177260&r1=177259&r2=177260&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Mon Mar 18 03:52:46 2013
@@ -241,6 +241,8 @@ void ScopedReport::AddMutex(const SyncVa
   rep_->mutexes.PushBack(rm);
   rm->id = s->uid;
   rm->destroyed = false;
+  rm->stack = 0;
+#ifndef TSAN_GO
   uptr ssz = 0;
   const uptr *stack = StackDepotGet(s->creation_stack_id, &ssz);
   if (stack) {
@@ -248,6 +250,7 @@ void ScopedReport::AddMutex(const SyncVa
     trace.Init(stack, ssz);
     rm->stack = SymbolizeStack(trace);
   }
+#endif
 }
 
 void ScopedReport::AddMutex(u64 id) {

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=177260&r1=177259&r2=177260&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Mon Mar 18 03:52:46 2013
@@ -48,17 +48,19 @@ struct OnCreatedArgs {
 
 void ThreadContext::OnCreated(void *arg) {
   thr = 0;
-  if (tid != 0) {
-    OnCreatedArgs *args = static_cast<OnCreatedArgs *>(arg);
-    args->thr->fast_state.IncrementEpoch();
-    // Can't increment epoch w/o writing to the trace as well.
-    TraceAddEvent(args->thr, args->thr->fast_state, EventTypeMop, 0);
-    args->thr->clock.set(args->thr->tid, args->thr->fast_state.epoch());
-    args->thr->fast_synch_epoch = args->thr->fast_state.epoch();
-    args->thr->clock.release(&sync);
-    StatInc(args->thr, StatSyncRelease);
-    creation_stack.ObtainCurrent(args->thr, args->pc);
-  }
+  if (tid == 0)
+    return;
+  OnCreatedArgs *args = static_cast<OnCreatedArgs *>(arg);
+  args->thr->fast_state.IncrementEpoch();
+  // Can't increment epoch w/o writing to the trace as well.
+  TraceAddEvent(args->thr, args->thr->fast_state, EventTypeMop, 0);
+  args->thr->clock.set(args->thr->tid, args->thr->fast_state.epoch());
+  args->thr->fast_synch_epoch = args->thr->fast_state.epoch();
+  args->thr->clock.release(&sync);
+  StatInc(args->thr, StatSyncRelease);
+  creation_stack.ObtainCurrent(args->thr, args->pc);
+  if (reuse_count == 0)
+    StatInc(args->thr, StatThreadMaxTid);
 }
 
 void ThreadContext::OnReset(void *arg) {
@@ -77,11 +79,12 @@ struct OnStartedArgs {
 
 void ThreadContext::OnStarted(void *arg) {
   OnStartedArgs *args = static_cast<OnStartedArgs*>(arg);
+  thr = args->thr;
   // RoundUp so that one trace part does not contain events
   // from different threads.
   epoch0 = RoundUp(epoch1 + 1, kTracePartSize);
   epoch1 = (u64)-1;
-  new(args->thr) ThreadState(CTX(), tid, unique_id,
+  new(thr) ThreadState(CTX(), tid, unique_id,
       epoch0, args->stk_addr, args->stk_size, args->tls_addr, args->tls_size);
 #ifdef TSAN_GO
   // Setup dynamic shadow stack.
@@ -104,8 +107,7 @@ void ThreadContext::OnStarted(void *arg)
   StatInc(thr, StatSyncAcquire);
   DPrintf("#%d: ThreadStart epoch=%zu stk_addr=%zx stk_size=%zx "
           "tls_addr=%zx tls_size=%zx\n",
-          tid, (uptr)epoch0, args->stk_addr, args->stk_size,
-          args->tls_addr, args->tls_size);
+          tid, (uptr)epoch0, stk_addr, stk_size, tls_addr, tls_size);
   thr->is_alive = true;
 }
 





More information about the llvm-commits mailing list