sanitizer_common: initialize sanitizer runtimes lazily from signal interceptors
authorDmitry Vyukov <dvyukov@google.com>
Thu, 13 Jul 2023 12:13:09 +0000 (14:13 +0200)
committerDmitry Vyukov <dvyukov@google.com>
Thu, 13 Jul 2023 14:28:25 +0000 (16:28 +0200)
commit13771793965bcda8951d6bdda1ea4ace658eca11
tree377a06a13db20c6d003cd875812428fae5db0fb6
parentd3140f9363878907a56474164a49148821571720
sanitizer_common: initialize sanitizer runtimes lazily from signal interceptors

Currently if a program calls sigaction very early (before non-lazy sanitizer
initialization, in particular if .preinit_array initialization is not enabled),
then sigaction will wrongly fail since the interceptor is not initialized yet.

In all other interceptors we do lazy runtime initialization for this reason,
but we don't do it in the signal interceptors.
Do lazy runtime initialization in signal interceptors as well.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D155188
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/lsan/lsan_interceptors.cpp
compiler-rt/lib/msan/msan_interceptors.cpp
compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
compiler-rt/lib/ubsan/ubsan_signals_standalone.cpp
compiler-rt/test/asan/lit.cfg.py
compiler-rt/test/lit.common.cfg.py
compiler-rt/test/ubsan/TestCases/Misc/Linux/sigaction.cpp [new file with mode: 0644]