[TSan] Revert r212531 and r212532.
authorAlexey Samsonov <vonosmas@gmail.com>
Tue, 8 Jul 2014 20:17:19 +0000 (20:17 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Tue, 8 Jul 2014 20:17:19 +0000 (20:17 +0000)
They cause "check-tsan" command to hang. Details in r212532 review thread.

llvm-svn: 212562

compiler-rt/lib/tsan/rtl/tsan_sync.cc
compiler-rt/lib/tsan/tests/unit/tsan_sync_test.cc

index 15392c9..8c48cad 100644 (file)
@@ -46,6 +46,7 @@ void SyncVar::Reset() {
   is_recursive = 0;
   is_broken = 0;
   is_linker_init = 0;
+  next = 0;
 
   clock.Zero();
   read_clock.Reset();
@@ -133,7 +134,7 @@ SyncVar* MetaMap::GetAndLock(ThreadState *thr, uptr pc,
   u32 myidx = 0;
   SyncVar *mys = 0;
   for (;;) {
-    u32 idx = idx0;
+    u32 idx = *meta;
     for (;;) {
       if (idx == 0)
         break;
@@ -156,10 +157,8 @@ SyncVar* MetaMap::GetAndLock(ThreadState *thr, uptr pc,
     }
     if (!create)
       return 0;
-    if (*meta != idx0) {
-      idx0 = *meta;
+    if (*meta != idx0)
       continue;
-    }
 
     if (myidx == 0) {
       const u64 uid = atomic_fetch_add(&uid_gen_, 1, memory_order_relaxed);
index 6f36c64..664ce7f 100644 (file)
@@ -108,16 +108,4 @@ TEST(MetaMap, MoveMemory) {
   m->FreeRange(thr, 0, (uptr)&block2[0], 4 * sizeof(u64));
 }
 
-TEST(MetaMap, ResetSync) {
-  ThreadState *thr = cur_thread();
-  MetaMap *m = &ctx->metamap;
-  u64 block[1] = {};  // fake malloc block
-  m->AllocBlock(thr, 0, (uptr)&block[0], 1 * sizeof(u64));
-  SyncVar *s = m->GetOrCreateAndLock(thr, 0, (uptr)&block[0], true);
-  s->Reset();
-  s->mtx.Unlock();
-  uptr sz = m->FreeBlock(thr, 0, (uptr)&block[0]);
-  EXPECT_EQ(sz, 1 * sizeof(u64));
-}
-
 }  // namespace __tsan