Page MenuHomePhabricator

[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage
ClosedPublic

Authored by yln on Jul 5 2022, 12:15 PM.

Details

Summary

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.

Diff Detail

Event Timeline

yln created this revision.Jul 5 2022, 12:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2022, 12:15 PM
yln requested review of this revision.Jul 5 2022, 12:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2022, 12:15 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

This is great. The interceptors are either installed correctly and the environment variable stripped for any possible children or it's an error (with useful instructions). This also removes the cumbersome statefulness of the process and the use of so-called strong-over-weak symbol overrides.

rsundahl accepted this revision.Jul 5 2022, 12:43 PM
This revision is now accepted and ready to land.Jul 5 2022, 12:43 PM
This revision was landed with ongoing or failed builds.Jul 7 2022, 4:39 PM
This revision was automatically updated to reflect the committed changes.