llvm-project/compiler-rt/lib/tsan/rtl
Marco Elver 303d278ad2 [tsan] Fix pthread_once() on Mac OS X
Change 636428c727 enabled BlockingRegion hooks for pthread_once().
Unfortunately this seems to cause crashes on Mac OS X which uses
pthread_once() from locations that seem to result in crashes:

| ThreadSanitizer:DEADLYSIGNAL
| ==31465==ERROR: ThreadSanitizer: stack-overflow on address 0x7ffee73fffd8 (pc 0x00010807fd2a bp 0x7ffee7400050 sp 0x7ffee73fffb0 T93815)
|     #0 __tsan::MetaMap::GetSync(__tsan::ThreadState*, unsigned long, unsigned long, bool, bool) tsan_sync.cpp:195 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x78d2a)
|     #1 __tsan::MutexPreLock(__tsan::ThreadState*, unsigned long, unsigned long, unsigned int) tsan_rtl_mutex.cpp:143 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x6cefc)
|     #2 wrap_pthread_mutex_lock sanitizer_common_interceptors.inc:4240 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x3dae0)
|     #3 flockfile <null>:2 (libsystem_c.dylib:x86_64+0x38a69)
|     #4 puts <null>:2 (libsystem_c.dylib:x86_64+0x3f69b)
|     #5 wrap_puts sanitizer_common_interceptors.inc (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x34d83)
|     #6 __tsan::OnPotentiallyBlockingRegionBegin() cxa_guard_acquire.cpp:8 (foo:x86_64+0x100000e48)
|     #7 wrap_pthread_once tsan_interceptors_posix.cpp:1512 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x2f6e6)

From the stack trace it can be seen that the caller is unknown, and the
resulting stack-overflow seems to indicate that whoever the caller is
does not have enough stack space or otherwise is running in a limited
environment not yet ready for full instrumentation.

Fix it by reverting behaviour on Mac OS X to not call BlockingRegion
hooks from pthread_once().

Reported-by: azharudd

Reviewed By: glider

Differential Revision: https://reviews.llvm.org/D108305
2021-08-19 13:17:45 +02:00
..
tsan.syms.extra [compiler-rt][tsan] Make fiber support in thread sanitizer dynamic linkable 2020-03-11 14:14:33 +01:00
tsan_clock.cpp tsan: remove the stats subsystem 2021-07-20 07:47:38 +02:00
tsan_clock.h [tsan] Remove special SyncClock::kInvalidTid 2021-04-30 13:39:15 -07:00
tsan_debugging.cpp tsan: introduce RawShadow type 2021-08-05 13:37:10 +02:00
tsan_defs.h tsan: add new trace 2021-08-16 10:24:11 +02:00
tsan_dense_alloc.h tsan: switch to the new sanitizer_common mutex 2021-07-23 09:13:26 +02:00
tsan_dispatch_defs.h [TSan][libdispatch] Ensure TSan dylib works on old systems 2020-08-18 18:34:14 -07:00
tsan_external.cpp tsan: don't include tsan_interceptors.h for Go 2021-08-05 16:56:28 +02:00
tsan_fd.cpp tsan: new MemoryAccess interface 2021-08-03 11:03:23 +02:00
tsan_fd.h tsan: introduce Tid and StackID typedefs 2021-07-31 09:05:31 +02:00
tsan_flags.cpp [sanitizers] Remove unneeded MaybeCall*DefaultOptions() and nullptr checks 2020-09-08 10:12:05 -07:00
tsan_flags.h Improve error message when '=' is missing in {ASAN,...}_OPTIONS. 2019-06-15 01:37:14 +00:00
tsan_flags.inc tsan: remove "expected" races 2021-07-31 08:54:49 +02:00
tsan_ignoreset.cpp tsan: minor IgnoreSet refactoring 2021-08-02 11:13:51 +02:00
tsan_ignoreset.h tsan: minor IgnoreSet refactoring 2021-08-02 11:13:51 +02:00
tsan_ilist.h tsan: add intrusive doubly-linked list 2021-07-29 17:07:27 +02:00
tsan_interceptors.h tsan: remove /**/ at the of multi-line macros 2021-07-29 07:50:09 +02:00
tsan_interceptors_libdispatch.cpp [TSan][libdispatch] Fix compilation error on Linux 2020-09-02 11:20:47 -07:00
tsan_interceptors_mac.cpp [tsan] Fix Darwin build after D106973 2021-07-28 16:40:18 -07:00
tsan_interceptors_mach_vm.cpp [TSan][Darwin] Handle NULL argument in interceptor 2020-08-24 11:36:02 -07:00
tsan_interceptors_posix.cpp [tsan] Fix pthread_once() on Mac OS X 2021-08-19 13:17:45 +02:00
tsan_interface.cpp tsan: avoid extra call indirection in unaligned access functions 2021-08-03 11:12:49 +02:00
tsan_interface.h [sanitizer] Remove cpplint annotations 2021-07-30 18:20:40 -07:00
tsan_interface.inc tsan: introduce kAccessExternalPC 2021-08-04 18:03:49 +02:00
tsan_interface_ann.cpp tsan: prevent insertion of memset into BenignRaceImpl 2021-07-31 09:17:14 +02:00
tsan_interface_ann.h
tsan_interface_atomic.cpp tsan: use DCHECK instead of CHECK in atomic functions 2021-08-04 13:23:57 +02:00
tsan_interface_java.cpp tsan: introduce RawShadow type 2021-08-05 13:37:10 +02:00
tsan_interface_java.h Remove NOLINTs from compiler-rt 2019-09-11 23:19:48 +00:00
tsan_malloc_mac.cpp compiler-rt: Rename .cc file in lib/tsan/rtl to .cpp 2019-08-01 14:22:42 +00:00
tsan_md5.cpp Remove NOLINTs from compiler-rt 2019-09-11 23:19:48 +00:00
tsan_mman.cpp tsan: introduce New/Alloc/Free helpers 2021-07-30 11:51:55 +02:00
tsan_mman.h tsan: Support constructor arguments via New 2021-07-30 12:49:08 +02:00
tsan_mutexset.cpp tsan: remove implicit memcpy in MutexSet::Desc::operator=() 2021-08-12 15:10:05 +02:00
tsan_mutexset.h tsan: remove implicit memcpy in MutexSet::Desc::operator=() 2021-08-12 15:10:05 +02:00
tsan_new_delete.cpp Remove NOLINTs from compiler-rt 2019-09-11 23:19:48 +00:00
tsan_platform.h tsan: fix latent bug in shadow computation 2021-08-13 16:38:56 +02:00
tsan_platform_linux.cpp tsan: remove indirection when selecting the active mapping 2021-08-10 20:07:31 +02:00
tsan_platform_mac.cpp tsan: fix build breakage due to AppMemBeg 2021-08-12 08:18:09 +02:00
tsan_platform_posix.cpp tsan: clean up and enable format string checking 2021-08-13 13:45:15 +02:00
tsan_platform_windows.cpp compiler-rt: Rename .cc file in lib/tsan/rtl to .cpp 2019-08-01 14:22:42 +00:00
tsan_ppc_regs.h
tsan_preinit.cpp compiler-rt: Rename .cc file in lib/tsan/rtl to .cpp 2019-08-01 14:22:42 +00:00
tsan_report.cpp tsan: clean up and enable format string checking 2021-08-13 13:45:15 +02:00
tsan_report.h tsan: introduce Tid and StackID typedefs 2021-07-31 09:05:31 +02:00
tsan_rtl.cpp tsan: add new trace 2021-08-16 10:24:11 +02:00
tsan_rtl.h tsan: add new trace 2021-08-16 10:24:11 +02:00
tsan_rtl_aarch64.S [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.6 2019-07-16 20:41:04 +00:00
tsan_rtl_amd64.S Revert "[TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.4" 2019-07-05 21:03:46 +00:00
tsan_rtl_mips64.S
tsan_rtl_mutex.cpp tsan: introduce kAccessFree 2021-08-04 18:03:41 +02:00
tsan_rtl_ppc64.S
tsan_rtl_proc.cpp compiler-rt: Rename .cc file in lib/tsan/rtl to .cpp 2019-08-01 14:22:42 +00:00
tsan_rtl_report.cpp Revert "[tsan] Fix GCC 8.3 build after D107911" 2021-08-17 19:26:20 +02:00
tsan_rtl_s390x.S [TSan] Add SystemZ longjmp support 2021-07-15 12:18:48 +02:00
tsan_rtl_thread.cpp tsan: add new trace 2021-08-16 10:24:11 +02:00
tsan_stack_trace.cpp tsan: introduce New/Alloc/Free helpers 2021-07-30 11:51:55 +02:00
tsan_stack_trace.h
tsan_suppressions.cpp Remove NOLINTs from compiler-rt 2019-09-11 23:19:48 +00:00
tsan_suppressions.h
tsan_symbolize.cpp tsan: introduce New/Alloc/Free helpers 2021-07-30 11:51:55 +02:00
tsan_symbolize.h
tsan_sync.cpp tsan: minor MetaMap tweaks 2021-08-04 13:20:44 +02:00
tsan_sync.h tsan: minor MetaMap tweaks 2021-08-04 13:20:44 +02:00
tsan_trace.h Revert "[tsan] Fix GCC 8.3 build after D107911" 2021-08-17 19:26:20 +02:00
tsan_update_shadow_word.inc [NFC][tsan] Rename _inl.h to .inc 2021-08-03 09:35:33 -07:00
tsan_vector_clock.cpp [tsan] Complete renaming kMaxSid to kThreadSlotCount 2021-08-02 16:52:29 +02:00
tsan_vector_clock.h tsan: add new vector clock 2021-08-02 13:45:31 +02:00