From 6e23467162423e7be4f2e8cc9fdb966d256877fb Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 8 Jul 2014 13:36:59 +0000 Subject: tsan: fix a potential hang idx0 is not updated in the branch, so if we take that branch idx0 will stay updated forever git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212532 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/tsan/rtl/tsan_sync.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/tsan/rtl/tsan_sync.cc') diff --git a/lib/tsan/rtl/tsan_sync.cc b/lib/tsan/rtl/tsan_sync.cc index 3952b2f67..3462b04c2 100644 --- a/lib/tsan/rtl/tsan_sync.cc +++ b/lib/tsan/rtl/tsan_sync.cc @@ -133,7 +133,7 @@ SyncVar* MetaMap::GetAndLock(ThreadState *thr, uptr pc, u32 myidx = 0; SyncVar *mys = 0; for (;;) { - u32 idx = *meta; + u32 idx = idx0; for (;;) { if (idx == 0) break; @@ -156,8 +156,10 @@ SyncVar* MetaMap::GetAndLock(ThreadState *thr, uptr pc, } if (!create) return 0; - if (*meta != idx0) + if (*meta != idx0) { + idx0 = *meta; continue; + } if (myidx == 0) { const u64 uid = atomic_fetch_add(&uid_gen_, 1, memory_order_relaxed); -- cgit v1.2.3