llvm-project/compiler-rt/lib
Kostya Kortchinsky 040c211bc4 [scudo] Fix improper TSD init after TLS destructors are called
Summary:
Some of glibc's own thread local data is destroyed after a user's thread local
destructors are called, via __libc_thread_freeres. This might involve calling
free, as is the case for strerror_thread_freeres.
If there is no prior heap operation in the thread, this free would end up
initializing some thread specific data that would never be destroyed properly
(as user's pthread destructors have already been called), while still being
deallocated when the TLS goes away. As a result, a program could SEGV, usually
in __sanitizer::AllocatorGlobalStats::Unregister, where one of the doubly linked
list links would refer to a now unmapped memory area.

To prevent this from happening, we will not do a full initialization from the
deallocation path. This means that the fallback cache & quarantine will be used
if no other heap operation has been called, and we effectively prevent the TSD
being initialized and never destroyed. The TSD will be fully initialized for all
other paths.

In the event of a thread doing only frees and nothing else, a TSD would never
be initialized for that thread, but this situation is unlikely and we can live
with that.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D37697

llvm-svn: 312939
2017-09-11 19:59:40 +00:00
..
BlocksRuntime [compiler-rt] Test commit: remove some trailing white spaces. 2017-08-25 19:36:30 +00:00
asan [asan] Use more generic string in error message 2017-09-09 05:58:52 +00:00
builtins [builtins] Prevent duplicate definitions for overridden functions 2017-08-30 17:12:57 +00:00
cfi CFI: Move STL allocator blacklist to clang 2017-08-04 20:04:01 +00:00
dfsan [sanitizer_common] Move filesystem-related code out of sanitizer_common.cc 2017-07-22 01:46:40 +00:00
esan [esan] Use stack_t instead of struct sigaltstack (PR34011) 2017-08-22 21:54:37 +00:00
fuzzer [libFuzzer] remove a couple of reduntant includes 2017-09-09 00:56:34 +00:00
interception [sanitizers CMake] NFC Refactor the logic for compiling and generating tests 2017-08-15 22:56:10 +00:00
lsan Add NetBSD support in lsan_interceptors.cc 2017-08-30 22:47:05 +00:00
msan [msan] Remove a stale fixme (NFC). 2017-09-06 00:28:52 +00:00
profile Revert r312240 2017-08-31 15:51:23 +00:00
safestack Enable SafeStack on NetBSD 2017-08-10 18:40:09 +00:00
sanitizer_common [sanitizer_common][Fuchsia] Update Fuchsia sanitizer markup 2017-09-06 00:00:46 +00:00
scudo [scudo] Fix improper TSD init after TLS destructors are called 2017-09-11 19:59:40 +00:00
stats Support compiler-rt builtins 2017-07-28 03:39:38 +00:00
tsan Add NetBSD support in tsan_interceptors.cc 2017-08-30 19:41:30 +00:00
ubsan [ubsan] Save binary name before parsing options 2017-09-11 18:32:51 +00:00
ubsan_minimal Disable ubsan-minimal on Darwin. 2017-08-29 21:15:08 +00:00
xray [XRay][compiler-rt] Enable the XRay compiler-rt unit tests. 2017-08-31 00:50:12 +00:00
CMakeLists.txt Move libFuzzer to compiler_rt. 2017-08-21 23:25:50 +00:00