This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Fix __cxa_guard_* interceptors on OS X
ClosedPublic

Authored by kubamracek on Nov 20 2015, 3:45 AM.

Details

Summary

This patch fixes the __cxa_guard_acquire, __cxa_guard_release and __cxa_guard_abort interceptors on OS X. They apparently work on Linux just by having the same name, but on OS X, we actually need to use TSAN_INTERCEPTOR.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek updated this revision to Diff 40763.Nov 20 2015, 3:45 AM
kubamracek retitled this revision from to [tsan] Fix __cxa_guard_* interceptors on OS X.
kubamracek updated this object.
kubamracek added reviewers: dvyukov, kcc, glider, samsonov.
dvyukov added inline comments.Nov 20 2015, 5:49 AM
lib/tsan/rtl/tsan_interceptors.cc
790 ↗(On Diff #40763)

I think this will break statically-linked libstdc++ (which we do have in some contexts).
Linux interceptors are especially defined as weak functions (so that they don't cause link errors when user defines them as well). So they silently auto-disable themselves when such symbol is already present in the binary.
If we link libstdc++ statically, it will bring own __cxa_guard_acquire which will silently replace our interceptor.
I have not tested it, though.

kubamracek updated this revision to Diff 40773.Nov 20 2015, 6:16 AM

I see. Changing patch to use #ifdef to use TSAN_INTERCEPTOR on OS X, and the current way on other platforms.

dvyukov accepted this revision.Nov 20 2015, 8:57 AM
dvyukov edited edge metadata.

LGTM with a nit

lib/tsan/rtl/tsan_interceptors.cc
789 ↗(On Diff #40773)

please add a comment for future generations as to why we are doing this

This revision is now accepted and ready to land.Nov 20 2015, 8:57 AM
This revision was automatically updated to reflect the committed changes.