This is an archive of the discontinued LLVM Phabricator instance.

[ubsan] Enable -fsanitize=vptr on Apple devices and simulators
ClosedPublic

Authored by vsk on Aug 24 2018, 3:56 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

vsk created this revision.Aug 24 2018, 3:56 PM
delcypher requested changes to this revision.Aug 26 2018, 3:57 PM
delcypher added inline comments.
clang/lib/Driver/ToolChains/Darwin.cpp
2254 ↗(On Diff #162493)

Could we apply De'Morgan's rule here and write that as

if (!(isTargetMacOS() && isMacosxVersionLT(10, 9)) {
  Res |= SanitizerKind::Vptr
}

I find that a bit easier to read.

Is there any particular reason why vptr isn't supported for old macOS versions? There's no mention of ios here which suggests that it's supported on all ios versions which seems like an odd disparity. Perhaps a comment briefly explaining why this is the case would be helpful?

This revision now requires changes to proceed.Aug 26 2018, 3:57 PM
vsk added inline comments.Aug 27 2018, 10:01 AM
clang/lib/Driver/ToolChains/Darwin.cpp
2254 ↗(On Diff #162493)

Sure.

MacOS versions older than 10.8 shipped a version of the C++ standard library which is incompatible with the vptr check's implementation (see: https://trac.macports.org/wiki/LibcxxOnOlderSystems). I'll add a comment to that effect.

As far as I know, all currently-supported versions of iOS ship libc++. I'll ask around and double-check, just to be safe.

vsk updated this revision to Diff 162732.Aug 27 2018, 1:12 PM

Address some review feedback.

I'm not sure whether iOS 4 is really supported anymore. There are a handful of code paths in the driver which handle that target, so I've added in a version check for it.

delcypher accepted this revision.Aug 28 2018, 10:13 AM

LGTM.

clang/test/Driver/fsanitize.c
426 ↗(On Diff #162732)

@vsk Interesting. This that what the iOS 4 target triple looked like.

This revision is now accepted and ready to land.Aug 28 2018, 10:13 AM
This revision was automatically updated to reflect the committed changes.