From 047ea1717be3abad0a6408da0fa70d8cac43a824 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 8 Jul 2014 20:17:19 +0000 Subject: [PATCH] [TSan] Revert r212531 and r212532. They cause "check-tsan" command to hang. Details in r212532 review thread. llvm-svn: 212562 --- compiler-rt/lib/tsan/rtl/tsan_sync.cc | 7 +++---- compiler-rt/lib/tsan/tests/unit/tsan_sync_test.cc | 12 ------------ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/compiler-rt/lib/tsan/rtl/tsan_sync.cc b/compiler-rt/lib/tsan/rtl/tsan_sync.cc index 15392c9578b3..8c48cadfb861 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_sync.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_sync.cc @@ -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); diff --git a/compiler-rt/lib/tsan/tests/unit/tsan_sync_test.cc b/compiler-rt/lib/tsan/tests/unit/tsan_sync_test.cc index 6f36c64a5565..664ce7f0dbc9 100644 --- a/compiler-rt/lib/tsan/tests/unit/tsan_sync_test.cc +++ b/compiler-rt/lib/tsan/tests/unit/tsan_sync_test.cc @@ -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