diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-09-01 12:13:18 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-09-01 12:13:18 +0000 |
commit | 1da1056127d1dbcacdd035eb4149257848f7c4df (patch) | |
tree | 0b90732e625b4efc95a883f3382bce5ee78ad388 /lib/tsan/rtl/tsan_rtl_mutex.cc | |
parent | 9adce675d5978dc8c584bafe724208bbab4ae72a (diff) | |
download | compiler-rt-1da1056127d1dbcacdd035eb4149257848f7c4df.tar.gz compiler-rt-1da1056127d1dbcacdd035eb4149257848f7c4df.tar.bz2 compiler-rt-1da1056127d1dbcacdd035eb4149257848f7c4df.tar.xz |
tsan: better diagnostics for mutex misuse
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163060 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_rtl_mutex.cc')
-rw-r--r-- | lib/tsan/rtl/tsan_rtl_mutex.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/tsan/rtl/tsan_rtl_mutex.cc b/lib/tsan/rtl/tsan_rtl_mutex.cc index efbaf9c3..45dc5591 100644 --- a/lib/tsan/rtl/tsan_rtl_mutex.cc +++ b/lib/tsan/rtl/tsan_rtl_mutex.cc @@ -79,6 +79,7 @@ void MutexLock(ThreadState *thr, uptr pc, uptr addr) { CHECK_GT(s->recursion, 0); } else { TsanPrintf("ThreadSanitizer WARNING: double lock\n"); + PrintCurrentStack(thr, pc); } if (s->recursion == 0) { StatInc(thr, StatMutexLock); @@ -106,11 +107,13 @@ void MutexUnlock(ThreadState *thr, uptr pc, uptr addr) { if (!s->is_broken) { s->is_broken = true; TsanPrintf("ThreadSanitizer WARNING: unlock of unlocked mutex\n"); + PrintCurrentStack(thr, pc); } } else if (s->owner_tid != thr->tid) { if (!s->is_broken) { s->is_broken = true; TsanPrintf("ThreadSanitizer WARNING: mutex unlock by another thread\n"); + PrintCurrentStack(thr, pc); } } else { s->recursion--; @@ -137,8 +140,10 @@ void MutexReadLock(ThreadState *thr, uptr pc, uptr addr) { thr->fast_state.IncrementEpoch(); TraceAddEvent(thr, thr->fast_state.epoch(), EventTypeRLock, addr); SyncVar *s = CTX()->synctab.GetAndLock(thr, pc, addr, false); - if (s->owner_tid != SyncVar::kInvalidTid) + if (s->owner_tid != SyncVar::kInvalidTid) { TsanPrintf("ThreadSanitizer WARNING: read lock of a write locked mutex\n"); + PrintCurrentStack(thr, pc); + } thr->clock.set(thr->tid, thr->fast_state.epoch()); thr->clock.acquire(&s->clock); s->last_lock = thr->fast_state.raw(); @@ -155,9 +160,11 @@ void MutexReadUnlock(ThreadState *thr, uptr pc, uptr addr) { thr->fast_state.IncrementEpoch(); TraceAddEvent(thr, thr->fast_state.epoch(), EventTypeRUnlock, addr); SyncVar *s = CTX()->synctab.GetAndLock(thr, pc, addr, true); - if (s->owner_tid != SyncVar::kInvalidTid) + if (s->owner_tid != SyncVar::kInvalidTid) { TsanPrintf("ThreadSanitizer WARNING: read unlock of a write " "locked mutex\n"); + PrintCurrentStack(thr, pc); + } thr->clock.set(thr->tid, thr->fast_state.epoch()); thr->fast_synch_epoch = thr->fast_state.epoch(); thr->clock.release(&s->read_clock); @@ -203,6 +210,7 @@ void MutexReadOrWriteUnlock(ThreadState *thr, uptr pc, uptr addr) { } else if (!s->is_broken) { s->is_broken = true; TsanPrintf("ThreadSanitizer WARNING: mutex unlock by another thread\n"); + PrintCurrentStack(thr, pc); } s->mtx.Unlock(); } |