[all-commits] [llvm/llvm-project] 0a9667: [Sanitizer][Darwin] Cleanup MaybeReexec() function...

Julian Lettner via All-commits all-commits at lists.llvm.org
Thu Jul 7 16:39:41 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0a9667b0f56b1b450abd02f74c6175bea54f832e
      https://github.com/llvm/llvm-project/commit/0a9667b0f56b1b450abd02f74c6175bea54f832e
  Author: Julian Lettner <julian.lettner at apple.com>
  Date:   2022-07-07 (Thu, 07 Jul 2022)

  Changed paths:
    M compiler-rt/lib/asan/asan_rtl.cpp
    M compiler-rt/lib/asan/tests/asan_test_main.cpp
    M compiler-rt/lib/memprof/memprof_rtl.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_common.h
    M compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
    M compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
    M compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
    M compiler-rt/lib/tsan/tests/rtl/tsan_test.cpp
    M compiler-rt/lib/tsan/tests/unit/tsan_unit_test_main.cpp
    M compiler-rt/test/asan/TestCases/Darwin/init_for_dlopen.cpp
    M compiler-rt/unittests/lit.common.unit.cfg.py

  Log Message:
  -----------
  [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




More information about the All-commits mailing list