This is an archive of the discontinued LLVM Phabricator instance.

[sanitizers] Explainer about dyld and weak overrides on Darwin. (NFC)
ClosedPublic

Authored by rsundahl on Mar 23 2023, 10:54 AM.

Details

Summary

Explain in the release notes that the Darwin dynamic linker (dyld) requires
that at least one weak symbol be present in any mach-o file that defines an
intended override of a sanitizer dylib weak reference.

rdar://103453678

Diff Detail

Event Timeline

rsundahl created this revision.Mar 23 2023, 10:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 10:54 AM
rsundahl requested review of this revision.Mar 23 2023, 10:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 10:54 AM
rsundahl updated this revision to Diff 507827.Mar 23 2023, 11:05 AM

Include a better summary

rsundahl edited the summary of this revision. (Show Details)Mar 23 2023, 11:06 AM
rsundahl added reviewers: yln, thetruestblue, wrotki.
yln added a comment.Mar 23 2023, 12:12 PM

Thanks Roy! I put my suggestions, but none of them are blocking.

llvm/docs/ReleaseNotes.rst
234

Here are my suggestions:

I feel that "weak overrides" is a bit ambiguous (what is weak? the overrider or the overridden?)

  • Let's use: "overrides of weak symbols" instead of "weak overrides"
  • Use __asan_default_options() which is more commonly used than __asan_on_error()
  • Choose one of the 2 options (to avoid confusion)
  • Mention from which deployment target / macOS version on this dyld behavior changes
237–239
241–244
rsundahl updated this revision to Diff 508190.Mar 24 2023, 12:18 PM

Reword for consistency.

rsundahl updated this revision to Diff 508193.EditedMar 24 2023, 12:23 PM

Changed order of examples to meet narrative.

I have reworded with your suggestions in mind @yln. Thank you for the input. I didn't add any minimum version information since the guidance is benign going backward and good hygiene moving forward.

yln added inline comments.Mar 24 2023, 2:39 PM
llvm/docs/ReleaseNotes.rst
238–240

What I meant above:

  • Let's be opinionated: instead of listing all the possible options (and providing no guidance which one to pick), we should recommend one.
  • Which one is the best? I am making the argument that having a dummy symbol is the preferable option:
    • The symbol name doubles as a short explanation/documentation
    • It's confusing that the "overrider" is weak (it doesn't have to be, we just want to opt-in the executable); my mental model was "strong definitions overwrite weak ones", which is wrong, but I think other people might fall into this trap as well. It confused Vitaly & Dmitry (two experts!) here: D146471
    • What happens if it's defined multiple times? Not important (as long as it compiles); but it would be important for the override (i.e., if they diverge -> trouble)

These 2 points are separate, and I feel more strongly about "recommend single option". Which ones do you agree/disagree with?

243–247
rsundahl retitled this revision from [sanitizers] Explainer about dyld and weak overrides on Darwin. to [sanitizers] Explainer about dyld and weak overrides on Darwin. (NFC).Mar 30 2023, 3:27 PM

Ping - Thank you.

thetruestblue accepted this revision.Mar 30 2023, 7:54 PM

Ping - Thank you.

I agree with most of Julian's comments. I think we should pick a "suggested worked around" and use that as an example rather than listing all the options. Those who understand the issue will understand what workarounds need to be added, and those who do not will be provided with a single fix that works, rather than being offered multiple workarounds for something they don't understand.

(When looking at the revision it looks like Julian's edits haven't been addressed cause of the "not done" tag, will you check the boxes of those items that have been completed?)

llvm/docs/ReleaseNotes.rst
243–247

I agree with this edit.

This revision is now accepted and ready to land.Mar 30 2023, 7:54 PM
rsundahl marked 6 inline comments as done.Apr 4 2023, 6:27 AM

Unresolved issues from this differential are resolved in D147526.