tsan: don't call dlsym during exit
authorDmitry Vyukov <dvyukov@google.com>
Tue, 21 Sep 2021 13:22:35 +0000 (15:22 +0200)
committerDmitry Vyukov <dvyukov@google.com>
Wed, 22 Sep 2021 05:11:59 +0000 (07:11 +0200)
commit20ee72d4ccb17c6f32641c690fa129475427ae45
tree419b990575cfee6e66a83eef2b716c1c1c16f0dd
parent957514eb9e712d9f0ea5c7afb2294c05da0c5e2d
tsan: don't call dlsym during exit

dlsym calls into dynamic linker which calls malloc and other things.
It's problematic to do it during the actual exit, because
it can happen from a singal handler or from within the runtime
after we reported the first bug, etc.
See https://github.com/google/sanitizers/issues/1440 for an example
(captured in the added test).
Initialize the callbacks during startup instead.

Depends on D110159.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D110166
compiler-rt/lib/tsan/rtl/tsan_interface.h
compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
compiler-rt/lib/tsan/rtl/tsan_rtl.h
compiler-rt/test/tsan/signal_exit.cpp [new file with mode: 0644]