From 22196e777c8f3753d1b71aa053aa038bea7ae16d Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 12 Mar 2014 14:55:20 +0000 Subject: [PATCH] tsan: fix deadlock in deadlock detector forget to unlock a mutex on one of the paths llvm-svn: 203663 --- compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h b/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h index 9bb44e41c911..4eb0d406a97d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h @@ -157,8 +157,10 @@ typename AddrHashMap::Cell *AddrHashMap::acquire(uptr addr, 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,