[compiler-rt] r203663 - tsan: fix deadlock in deadlock detector

Dmitry Vyukov dvyukov at google.com
Wed Mar 12 07:55:20 PDT 2014


Author: dvyukov
Date: Wed Mar 12 09:55:20 2014
New Revision: 203663

URL: http://llvm.org/viewvc/llvm-project?rev=203663&view=rev
Log:
tsan: fix deadlock in deadlock detector
forget to unlock a mutex on one of the paths


Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h?rev=203663&r1=203662&r2=203663&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h Wed Mar 12 09:55:20 2014
@@ -157,8 +157,10 @@ typename AddrHashMap<T, kSize>::Cell *Ad
   for (;;) {
     Cell *c = &table_[h];
     uptr addr1 = atomic_load(&c->addr, memory_order_acquire);
-    if (addr1 == addr)  // another thread has inserted it ahead of us
+    if (addr1 == addr) {  // another thread has inserted it ahead of us
+      c0->mtx.Unlock();
       return c;
+    }
     // Skip kLocked, since we hold the home cell mutex, it can't be our elem.
     if ((addr1 == 0 || addr1 == kRemoved) &&
         atomic_compare_exchange_strong(&c->addr, &addr1, kLocked,





More information about the llvm-commits mailing list