This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Allow sanitizing libcxx with ASan+UBSan simultaneously
ClosedPublic

Authored by kubamracek on Sep 14 2016, 9:16 AM.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 71372.Sep 14 2016, 9:16 AM
kubamracek retitled this revision from to [libcxx] Allow sanitizing libcxx with ASan+UBSan simultaneously.
kubamracek updated this object.
kubamracek added reviewers: EricWF, compnerd, dexonsmith.
kubamracek added a subscriber: zaks.anna.
filcab added a subscriber: filcab.Sep 14 2016, 9:34 AM
filcab added inline comments.
test/libcxx/test/config.py
628

Why don't you sanitize those?

IIRC, vptr needs stuff from libc++abi, not libc++. Is there a problem with this sanitizer on libcxx tests?
function is not available on OS X, so no need to include it. (SanitizerMask Darwin::getSupportedSanitizers() const in Driver/ToolChains.cpp)
Why remove float-divide-by-zero?

Please add a comment explaining these (also, remove any -fno-sanitize=... that you can :-) )

kubamracek added inline comments.Sep 14 2016, 9:39 AM
test/libcxx/test/config.py
628

It’s the same flags that are used for UBSan-only builds, see a few lines below. I don’t know why exactly we’re using that and it’s not the point of this patch to change them.

We can take a look at which flags should be enabled/disabled and document that, but that should happen in a separate revision.

Factoring out the UBSan flags so they’re not duplicated.

Shouldn't this be '-fsanitize="undefined;address"'?

We’re appending to the flags (with +=), so this should work as well (having -fsanitize=address -fsanitize=undefined).

filcab accepted this revision.Sep 14 2016, 10:51 AM
filcab added a reviewer: filcab.

LGTM too. We should check if those -fno-sanitize flags are actually needed, later.

lib/CMakeLists.txt
49

Please add these to line 40, above (easy to miss on Duncan's message).

This revision is now accepted and ready to land.Sep 14 2016, 10:51 AM
This revision was automatically updated to reflect the committed changes.

Duncan sent some more comments in mail:

It'd be nice to factor this out more somehow. Can't UBSan be combined with all the others?

Yes, UBSan can be used at least with TSan and MSan, not sure about the other sanitizers and -fsanitize options. However, LLVM currently only allows some very specific options in LLVM_USE_SANITIZER (see llvm/cmake/modules/HandleLLVMOptions.cmake), and currently it only allows ASan+UBSan together. Let’s leave generalizing this for later, when someone’s actually interested in running a different sanitizer combination.