llvm-project/compiler-rt
Dmitry Vyukov 3056ccdbae tsan: fix deadlock/crash in signal handling
We set in_blocking_func around some blocking C functions so that we don't
delay signal infinitely (if in_blocking_func is set we deliver signals
synchronously).

However, pthread_join is blocking but also call munmap/free to free thread
resources. If we are inside the munmap/free interceptors called from
pthread_join and deliver a signal synchronously, it can lead to deadlocks
and crashes since we re-enter runtime and try to lock the same mutexes
or use the same per-thread data structures.

If we re-enter runtime via an interceptor when in_blocking_func is set,
temporary reset in_blocking_func around the interceptor and restore it back
when we return from the recursive interceptor.

Also move in_blocking_func from ThreadSignalContext to ThreadContext
so that we can CHECK that it's not set in SlotLocker ctor.

Fixes https://github.com/google/sanitizers/issues/1540

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D127845
2022-09-30 14:23:46 +02:00
..
cmake [compiler-rt][builtins] Enable more warnings in add_security_warnings 2022-09-14 12:55:56 -07:00
docs Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too" 2022-08-18 22:46:32 -04:00
include [ORC-RT] Drop the 'clang_rt.' prefix from the ORC runtime. 2022-09-12 16:48:20 -07:00
lib tsan: fix deadlock/crash in signal handling 2022-09-30 14:23:46 +02:00
test tsan: fix deadlock/crash in signal handling 2022-09-30 14:23:46 +02:00
tools
unittests [Sanitizer][Darwin] Cleanup MaybeReexec() function and usage 2022-07-08 14:31:42 -07:00
utils [compiler-rt] NFC: Fix trivial typo 2021-09-04 14:12:58 +05:30
www Remove references to old mailing lists that have moved to discourse. Replace with links to discourse. 2022-07-22 09:59:03 -07:00
.clang-tidy
.gitignore
CMakeLists.txt Revert "[CMake] Use libcxx targets for in-tree sanitizer C++ ABI" 2022-09-30 05:52:49 +00:00
CODE_OWNERS.TXT CODE_OWNERS: update information for builtins 2022-04-25 15:36:52 +00:00
CREDITS.TXT
LICENSE.TXT
README.txt

README.txt

Compiler-RT
================================

This directory and its subdirectories contain source code for the compiler
support routines.

Compiler-RT is open source software. You may freely distribute it under the
terms of the license agreement found in LICENSE.txt.

================================