This is an archive of the discontinued LLVM Phabricator instance.

[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.

This change bricks the old tsan runtime. Should we remove the call from rtl-old as well? Or is rtl-old not maintained at all?

yln added a subscriber: dvyukov.Sep 21 2022, 2:44 PM

This change bricks the old tsan runtime. Should we remove the call from rtl-old as well? Or is rtl-old not maintained at all?

Yes, this was on oversight: https://reviews.llvm.org/D134389

Are you still using the old TSan runtime? @dvyukov what is the plan/timeline for removing it?

This change bricks the old tsan runtime. Should we remove the call from rtl-old as well? Or is rtl-old not maintained at all?

Yes, this was on oversight: https://reviews.llvm.org/D134389

Are you still using the old TSan runtime? @dvyukov what is the plan/timeline for removing it?

I dunno. As far as I know only @thakis used it. Nico, is it still needed?

yln added inline comments.Feb 27 2023, 2:51 PM
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1012

It looks like __sanitizer_report_error_summary isn't a good function to use here, since it can be overridden by the client.