Page MenuHomePhabricator

[tsan] Fix fork() and fork-based tests for OS X

Authored by kubamracek on Mar 23 2016, 11:16 AM.



On OS X, fork() under TSan asserts (in debug builds only) because REAL(fork) calls some intercepted functions, which check that no internal locks are held via CheckNoLocks(). But the wrapper of fork intentionally holds some locks. The assert backtrace:

FATAL: ThreadSanitizer CHECK failed: .../llvm/projects/compiler-rt/lib/tsan/rtl/ "((locked_[i])) == ((0))" (0x224, 0x0)
frame #6: 0x00000001000b3df1 libclang_rt.tsan_osx_dynamic.dylib`__tsan::TsanCheckFailed(file=".../llvm/projects/compiler-rt/lib/tsan/rtl/", line=169, cond="((locked_[i])) == ((0))", v1=548, v2=0) + 97 at
frame #7: 0x0000000100009289 libclang_rt.tsan_osx_dynamic.dylib`__sanitizer::CheckFailed(file=".../llvm/projects/compiler-rt/lib/tsan/rtl/", line=169, cond="((locked_[i])) == ((0))", v1=548, v2=0) + 73 at
frame #8: 0x000000010008158c libclang_rt.tsan_osx_dynamic.dylib`__tsan::InternalDeadlockDetector::CheckNoLocks(this=0x00000001010465b8) + 140 at
frame #9: 0x00000001000815c5 libclang_rt.tsan_osx_dynamic.dylib`__tsan::CheckNoLocks(thr=0x0000000100ffe000) + 21 at
frame #10: 0x000000010003d55e libclang_rt.tsan_osx_dynamic.dylib`__tsan::ScopedInterceptor::~ScopedInterceptor(this=0x00007fff5fbff838) + 174 at
frame #11: 0x000000010003d7fe libclang_rt.tsan_osx_dynamic.dylib`__tsan::ScopedInterceptor::~ScopedInterceptor(this=0x00007fff5fbff838) + 14 at
frame #12: 0x00000001000bfcaf libclang_rt.tsan_osx_dynamic.dylib`::wrap_OSSpinLockLock(lock=0x0000000100ffd5ac) + 335 at
frame #13: 0x00007fff99dd6d7d libsystem_pthread.dylib`_pthread_fork_prepare + 43
frame #14: 0x00007fff9a4c7a74 libSystem.B.dylib`libSystem_atfork_prepare + 24
frame #15: 0x00007fff9f21af9c libsystem_c.dylib`fork + 12
frame #16: 0x0000000100043e5d libclang_rt.tsan_osx_dynamic.dylib`::wrap_fork(fake=17065400) + 125 at
frame #17: 0x0000000100000d98`main + 40 at [opt]
frame #18: 0x00007fff9c4875ad libdyld.dylib`start + 1

This patch fixes that by using ScopedIgnoreInterceptors during the call to REAL(fork). After that, all the fork-based tests seem to pass on OS X, so let's just remove all the UNSUPPORTED: darwin annotations we have.

Diff Detail


Event Timeline

kubamracek retitled this revision from to [tsan] Fix fork() and fork-based tests for OS X.
kubamracek updated this object.
kubamracek added reviewers: dvyukov, kcc, glider, samsonov.
dvyukov accepted this revision.Mar 24 2016, 1:41 AM
dvyukov edited edge metadata.

LGTM with a nit

2173 ↗(On Diff #51450)

Please add a comment here explaining why we do this.

This revision is now accepted and ready to land.Mar 24 2016, 1:41 AM
This revision was automatically updated to reflect the committed changes.