[compiler-rt] r212532 - tsan: fix a potential hang

Dmitry Vyukov dvyukov at google.com
Tue Jul 8 06:37:00 PDT 2014


Author: dvyukov
Date: Tue Jul  8 08:36:59 2014
New Revision: 212532

URL: http://llvm.org/viewvc/llvm-project?rev=212532&view=rev
Log:
tsan: fix a potential hang

idx0 is not updated in the branch,
so if we take that branch idx0 will stay updated forever



Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc?rev=212532&r1=212531&r2=212532&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc Tue Jul  8 08:36:59 2014
@@ -133,7 +133,7 @@ SyncVar* MetaMap::GetAndLock(ThreadState
   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
     }
     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);





More information about the llvm-commits mailing list