[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage
authorJulian Lettner <julian.lettner@apple.com>
Fri, 1 Jul 2022 18:05:40 +0000 (11:05 -0700)
committerJulian Lettner <julian.lettner@apple.com>
Thu, 7 Jul 2022 23:39:27 +0000 (16:39 -0700)
commit0a9667b0f56b1b450abd02f74c6175bea54f832e
treeb42317c4fa1ad97aa01f41c5d8af9784bc2a1d60
parente4c5bca597a6f12e8f789a53e862387b9808ff48
[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage

While investigating another issue, I noticed that `MaybeReexec()` never
actually "re-executes via `execv()`" anymore.  `DyldNeedsEnvVariable()`
only returned true on macOS 10.10 and below.

Usually, I try to avoid "unnecessary" cleanups (it's hard to be certain
that there truly is no fallout), but I decided to do this one because:

* I initially tricked myself into thinking that `MaybeReexec()` was
  relevant to my original investigation (instead of being dead code).
* The deleted code itself is quite complicated.
* Over time a few other things were mushed into `MaybeReexec()`:
  initializing `MonotonicNanoTime()`, verifying interceptors are
  working, and stripping the `DYLD_INSERT_LIBRARIES` env var to avoid
  problems when forking.
* This platform-specific thing leaked into `sanitizer_common.h`.
* The `ReexecDisabled()` config nob relies on the "strong overrides weak
  pattern", which is now problematic and can be completely removed.
* `ReexecDisabled()` actually hid another issue with interceptors not
  working in unit tests.  I added an explicit `verify_interceptors`
  (defaults to `true`) option instead.

Differential Revision: https://reviews.llvm.org/D129157
14 files changed:
compiler-rt/lib/asan/asan_rtl.cpp
compiler-rt/lib/asan/tests/asan_test_main.cpp
compiler-rt/lib/memprof/memprof_rtl.cpp
compiler-rt/lib/sanitizer_common/sanitizer_common.h
compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
compiler-rt/lib/tsan/tests/rtl/tsan_test.cpp
compiler-rt/lib/tsan/tests/unit/tsan_unit_test_main.cpp
compiler-rt/test/asan/TestCases/Darwin/init_for_dlopen.cpp
compiler-rt/unittests/lit.common.unit.cfg.py