odyaka341 / thread-sanitizer

Automatically exported from code.google.com/p/thread-sanitizer
0 stars 0 forks source link

deadlock detector conflicts with __tsan_java_mutex_unlock #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
% clang -fsanitize=thread 
~/llvm/projects/compiler-rt/test/tsan/java_lock_rec.cc  && 
TSAN_OPTIONS=detect_deadlocks=1  ./a.out 
FATAL: ThreadSanitizer CHECK failed: 
/home/kcc/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_dete
ctor.h:86 "((bv_.clearBit(lock_id))) != (0)" (0x0, 0x0)
    #0 __tsan::PrintCurrentStackSlow() /home/kcc/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc:734 (a.out+0x00000008351c)
    #1 __tsan::TsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) /home/kcc/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc:44 (a.out+0x0000000835f3)
    #2 __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) /home/kcc/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_common.cc:76 (a.out+0x000000089373)
    #3 __sanitizer::DeadlockDetectorTLS<__sanitizer::TwoLevelBitVector<1ul, __sanitizer::BasicBitVector<unsigned long> > >::removeLock(unsigned long) /home/kcc/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector.h:86 (a.out+0x00000008a0db)
    #4 __sanitizer::DeadlockDetector<__sanitizer::TwoLevelBitVector<1ul, __sanitizer::BasicBitVector<unsigned long> > >::onUnlock(__sanitizer::DeadlockDetectorTLS<__sanitizer::TwoLevelBitVector<1ul, __sanitizer::BasicBitVector<unsigned long> > >*, unsigned long) /home/kcc/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector.h:329 (a.out+0x00000008a0db)
    #5 __sanitizer::DD::MutexBeforeUnlock(__sanitizer::DDCallback*, __sanitizer::DDMutex*, bool) /home/kcc/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector1.cc:169 (a.out+0x00000008a0db)
    #6 __tsan::MutexUnlock(__tsan::ThreadState*, unsigned long, unsigned long, bool) /home/kcc/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc:220 (a.out+0x0000000800f2)
    #7 __tsan_java_mutex_unlock /home/kcc/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_java.cc:169 (a.out+0x000000070339)
    #8 Thread(void*) <null>:0 (a.out+0x000000099acf)
    #9 __tsan_thread_start_func /home/kcc/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:837 (a.out+0x000000023b51)
    #10 start_thread /build/buildd/eglibc-2.15/nptl/pthread_create.c:308 (libpthread.so.0+0x000000007e99)
    #11 clone /build/buildd/eglibc-2.15/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:112 (libc.so.6+0x0000000f43fc)

% 

Dmitry, any ideas? 

Original issue reported on code.google.com by konstant...@gmail.com on 8 Jul 2014 at 12:56

GoogleCodeExporter commented 9 years ago
Java lock are weird. java_lock_rec is a test for "multi-level" unlock. I.e. 
when you do lock, lock, lock, and then a single multi-level unlock and it 
unlocks all 3 locks; and then you do lock(3) and grab back all three locks; and 
then unlock, unlock, unlock.
I guess deadlock detector does not expect such weirdness.

Original comment by dvyu...@google.com on 8 Jul 2014 at 1:01

GoogleCodeExporter commented 9 years ago
Thanks for the explanation. 
Fix: http://llvm.org/viewvc/llvm-project?view=revision&revision=212529

Original comment by konstant...@gmail.com on 8 Jul 2014 at 1:25