Interceptors using ScopedInteceptor should never call into user's code before the ScopedInterceptor is out of scope (and its destructor is called). Let's add a DCHECK to enforce that.
Details
Details
- Reviewers
kcc glider dvyukov samsonov - Commits
- rG15dd456236c3: [tsan] Add a DCHECK to verify __tsan_read* and __tsan_write function aren't…
rCRT255996: [tsan] Add a DCHECK to verify __tsan_read* and __tsan_write function aren't…
rL255996: [tsan] Add a DCHECK to verify __tsan_read* and __tsan_write function aren't…
Diff Detail
Diff Detail
Event Timeline
Comment Actions
This currently fails several GCD tests (fix is in http://reviews.llvm.org/D15419), plus the sigsuspend.cc test. This fails because a signal handler (do_nothing_signal_handler) is called via this backtrace:
frame #0: __sanitizer::CheckFailed "((thr->in_interceptor_count)) == ((0))" at sanitizer_common.cc:158 frame #1:__tsan_write1(addr=0x0000000100001080) + 146 at tsan_interface_inl.h:39 frame #2: sigsuspend.cc.tmp`::do_nothing_signal_handler() + 47 at sigsuspend.cc:17 [opt] frame #3: libsystem_platform.dylib`_sigtramp + 26 frame #4: libsystem_kernel.dylib`__sigsuspend + 11 frame #5: wrap_sigsuspend(mask=0x00007fff5fbff9cc) + 142 at tsan_interceptors.cc:2104 frame #6: sigsuspend.cc.tmp`main + 157 at sigsuspend.cc:35 [opt]
...and the wrap_sigsuspend interceptor calls REAL(sigsuspend) while ScopedInterceptor is still in scope:
TSAN_INTERCEPTOR(int, sigsuspend, const __sanitizer_sigset_t *mask) { SCOPED_TSAN_INTERCEPTOR(sigsuspend, mask); return REAL(sigsuspend)(mask); }
Comment Actions
There are some failures on the Linux buildbot, http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/13046/steps/test%20tsan%20in%20debug%20compiler-rt%20build/logs/stdio:
Failing Tests (3): ThreadSanitizer :: dl_iterate_phdr.cc ThreadSanitizer :: signal_sync.cc ThreadSanitizer :: signal_thread.cc
The "dl_iterate_phdr.cc" one should be easy to fix, we just need to annotate the callback from the interceptor into user code. However, I don't know yet what's the right solution for the signal tests.