<div dir="ltr">Yes, I think it would be possible to combine UBSan with TSan and MSan in the same way. I planned to do experiment with that soon.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 2, 2015 at 5:56 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That's unfortunate; "can be used in any build without restrictions" used to be one of UBSan's selling points. Would we be able to make these work again by linking the UBSan runtime in the MSan and TSan ones too, or is the issue more complicated than that?<div><div class="h5"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 2, 2015 at 4:53 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">UBSan+MSan and UBSan+TSan combinations are currently not supported. We print a diagnostic in this case.</div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Thu, Apr 2, 2015 at 3:24 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">How does this affect UBSan + MSan and UBSan + TSan builds?</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 1, 2015 at 3:42 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: samsonov<br>
Date: Wed Apr 1 17:42:25 2015<br>
New Revision: 233860<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=233860&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=233860&view=rev</a><br>
Log:<br>
[UBSan] Embed UBSan into ASan runtime (Clang part).<br>
<br>
Summary:<br>
Change the way we use ASan and UBSan together. Instead of keeping two<br>
separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan<br>
into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on<br>
a platform, all UBSan sources are just compiled into dummy empty object<br>
files. UBSan initialization code (e.g. flag parsing) is directly called<br>
from ASan initialization, so we are able to enforce correct<br>
initialization order.<br>
<br>
This mirrors the approach we already use for ASan+LSan. This change doesn't<br>
modify the way we use standalone UBSan.<br>
<br>
Test Plan: regression test suite<br>
<br>
Reviewers: kubabrecka, zaks.anna, kcc, rsmith<br>
<br>
Subscribers: cfe-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D8645" target="_blank">http://reviews.llvm.org/D8645</a><br>
<br>
Modified:<br>
cfe/trunk/lib/Driver/SanitizerArgs.cpp<br>
cfe/trunk/lib/Driver/ToolChains.cpp<br>
cfe/trunk/lib/Driver/Tools.cpp<br>
cfe/trunk/test/Driver/sanitizer-ld.c<br>
<br>
Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=233860&r1=233859&r2=233860&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=233860&r1=233859&r2=233860&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)<br>
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Wed Apr 1 17:42:25 2015<br>
@@ -159,7 +159,8 @@ static bool getDefaultBlacklist(const Dr<br>
}<br>
<br>
bool SanitizerArgs::needsUbsanRt() const {<br>
- return !UbsanTrapOnError && hasOneOf(Sanitizers, NeedsUbsanRt);<br>
+ return !UbsanTrapOnError && hasOneOf(Sanitizers, NeedsUbsanRt) &&<br>
+ !Sanitizers.has(SanitizerKind::Address);<br>
}<br>
<br>
bool SanitizerArgs::requiresPIE() const {<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=233860&r1=233859&r2=233860&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=233860&r1=233859&r2=233860&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Apr 1 17:42:25 2015<br>
@@ -338,6 +338,9 @@ void DarwinClang::AddLinkSanitizerLibArg<br>
OS + "_dynamic.dylib").str(),<br>
/*AlwaysLink*/ true, /*IsEmbedded*/ false,<br>
/*AddRPath*/ true);<br>
+ // Add explicit dependcy on -lc++abi, as -lc++ doesn't re-export<br>
+ // all RTTI-related symbols that UBSan uses.<br>
+ CmdArgs.push_back("-lc++abi");<br>
}<br>
<br>
void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,<br>
@@ -401,9 +404,6 @@ void DarwinClang::AddLinkRuntimeLibArgs(<br>
<< "-fsanitize=undefined";<br>
} else {<br>
AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");<br>
- // Add explicit dependcy on -lc++abi, as -lc++ doesn't re-export<br>
- // all RTTI-related symbols that UBSan uses.<br>
- CmdArgs.push_back("-lc++abi");<br>
}<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=233860&r1=233859&r2=233860&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=233860&r1=233859&r2=233860&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Apr 1 17:42:25 2015<br>
@@ -2307,18 +2307,10 @@ collectSanitizerRuntimes(const ToolChain<br>
StaticRuntimes.push_back("msan");<br>
if (SanArgs.needsTsanRt())<br>
StaticRuntimes.push_back("tsan");<br>
- // WARNING: UBSan should always go last.<br>
if (SanArgs.needsUbsanRt()) {<br>
- // Check if UBSan is combined with another sanitizers.<br>
- if (StaticRuntimes.empty()) {<br>
- StaticRuntimes.push_back("ubsan_standalone");<br>
- if (SanArgs.linkCXXRuntimes())<br>
- StaticRuntimes.push_back("ubsan_standalone_cxx");<br>
- } else {<br>
- StaticRuntimes.push_back("ubsan");<br>
- if (SanArgs.linkCXXRuntimes())<br>
- StaticRuntimes.push_back("ubsan_cxx");<br>
- }<br>
+ StaticRuntimes.push_back("ubsan_standalone");<br>
+ if (SanArgs.linkCXXRuntimes())<br>
+ StaticRuntimes.push_back("ubsan_standalone_cxx");<br>
}<br>
}<br>
<br>
<br>
Modified: cfe/trunk/test/Driver/sanitizer-ld.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=233860&r1=233859&r2=233860&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=233860&r1=233859&r2=233860&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)<br>
+++ cfe/trunk/test/Driver/sanitizer-ld.c Wed Apr 1 17:42:25 2015<br>
@@ -227,8 +227,7 @@<br>
// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX %s<br>
// CHECK-ASAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"<br>
// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"<br>
-// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"<br>
-// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx<br>
+// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan<br>
// CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"<br>
// CHECK-ASAN-UBSAN-LINUX: "-lpthread"<br>
<br>
@@ -238,8 +237,8 @@<br>
// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX-CXX %s<br>
// CHECK-ASAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"<br>
// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"<br>
-// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"<br>
-// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"<br>
+// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan_cxx-i386.a" "-no-whole-archive"<br>
+// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan<br>
// CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"<br>
// CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br><div><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</font></span></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div>