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

Julian Lettner via All-commits all-commits at lists.llvm.org
Fri Jul 8 14:31:56 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ca50840b5bc0679e824850ca4fd322504d6713a0
      https://github.com/llvm/llvm-project/commit/ca50840b5bc0679e824850ca4fd322504d6713a0
  Author: Julian Lettner <julian.lettner at apple.com>
  Date:   2022-07-08 (Fri, 08 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