Page MenuHomePhabricator

[lldb/test][Darwin] Ask dyld where the real python is
ClosedPublic

Authored by vsk on Thu, May 7, 4:14 PM.

Details

Summary

On macOS, we can't do the DYLD_INSERT_LIBRARIES trick with a shim
python binary as the ASan interceptors get loaded too late. Find the
"real" python binary, copy it, and invoke it.

Hopefully this makes the GreenDragon and swift-ci sanitizer bots
happy...

I tested this out by running `../llvm-macosx-x86_64/bin/llvm-lit test
--filter TestNSDictionarySynthetic.py` in an ASanified swift-lldb build
directory and it worked (i.e. no more "interceptors loaded too late"
messages).

Diff Detail

Event Timeline

vsk created this revision.Thu, May 7, 4:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptThu, May 7, 4:14 PM

Thanks Vedant for coming up with a structural solution to this problem!

lldb/test/API/lldbtest.py
37

This would have to run under the Python in executable, not the one lit is running with.

vsk updated this revision to Diff 262792.Thu, May 7, 5:21 PM

Query dyld while running within the right python process.

JDevlieghere added inline comments.Thu, May 7, 6:11 PM
lldb/test/API/lldbtest.py
86

SIP still matters here, which is why we need to copy the python binary and not just invoke it with the result from get_darwin_real_python.py. Can you merge the two comments?

I also think that we might set DYLD_INSERT_LIBRARIES unconditionally on other hosts. Can we guard this whole thing with a check for macOS?

vsk updated this revision to Diff 262799.Thu, May 7, 6:21 PM
  • Reinstated comment about SIP to explain why we copy python
  • Added a platform check
This revision is now accepted and ready to land.Thu, May 7, 11:46 PM
This revision was automatically updated to reflect the committed changes.