This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Fix 'dyld: Symbol not found: _memmem' linkage error on Darwin 10.6
ClosedPublic

Authored by m.ostapenko on Jan 30 2017, 9:21 AM.

Details

Summary

This patch tries to fix sanitizer linkage errors on Darwin 10.6 (GCC's pr78663 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78663).
Since I don't have Darwin target available, I'm posting original patch for GCC as it is present in GCC bugzilla to initiate further discussion.
If (ugly) ifdef stuff is not acceptable, we can probably just introduce weak hooks for mmap and munmap that will fall back to regular mmap and munmap calls accordingly. For memmem we can probably print a warning.

Diff Detail

Repository
rL LLVM

Event Timeline

m.ostapenko created this revision.Jan 30 2017, 9:21 AM
kubamracek edited edge metadata.Feb 1 2017, 5:38 AM

Maxim, I'm generally fine with this (a few nits), but 10.6 is really ancient today. We currently only support *running* (i.e. deployment target) on 10.9+, and building on 10.10+. All our Darwin buildbots (http://lab.llvm.org:8080/) are 10.10+.

I'm afraid that there will always be changes that break more and more stuff on 10.6 or even 10.7 and 10.8. If these are something that you need supported, we should get public buildbots of these configurations, and I'm afraid we can't provide them.

lib/sanitizer_common/sanitizer_mac.cc
96 ↗(On Diff #86300)

typo "one"

107 ↗(On Diff #86300)

clang-format please

199 ↗(On Diff #86300)

drop the space at the start of the line

lib/sanitizer_common/sanitizer_platform_interceptors.h
51 ↗(On Diff #86300)

drop the space between # and define

56–60 ↗(On Diff #86300)

I don't think this is the right place for this. Can we put something like the following somewhere close to original place where SANITIZER_INTERCEPT_MEMMEM was defined:

#define SI_MAC_DEPLOYMENT_BELOW_10_7 ...
// memmem on Darwin doesn't exist on 10.6
#define SANITIZER_INTERCEPT_MEMMEM SI_NOT_WINDOWS && !SI_MAC_DEPLOYMENT_BELOW_10_7

?

Maxim, I'm generally fine with this (a few nits), but 10.6 is really ancient today. We currently only support *running* (i.e. deployment target) on 10.9+, and building on 10.10+. All our Darwin buildbots (http://lab.llvm.org:8080/) are 10.10+.

Thank you for this information. Just to clarify: 10.6 means Darwin 10 (MACOS_VERSION_SNOW_LEOPARD), right? Because this is an original platform where linkage error occurred.

I'm afraid that there will always be changes that break more and more stuff on 10.6 or even 10.7 and 10.8. If these are something that you need supported, we should get public buildbots of these configurations, and I'm afraid we can't provide them.

Okay, got it, we'll probably need to disable sanitizers on Darwin 10 and older in future GCC releases (or just fix problems locally).

Thank you for this information. Just to clarify: 10.6 means Darwin 10 (MACOS_VERSION_SNOW_LEOPARD), right? Because this is an original platform where linkage error occurred.

Correct, macOS 10.6 is Snow Leopard.

m.ostapenko updated this revision to Diff 86628.Feb 1 2017, 6:51 AM

Updating according to Kuba's nits.

kubamracek accepted this revision.Feb 1 2017, 9:15 AM
This revision is now accepted and ready to land.Feb 1 2017, 9:15 AM
This revision was automatically updated to reflect the committed changes.