<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 14, 2016 at 3:34 PM, Eric Fiselier via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</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"><span class=""><span style="font-size:12.8px">Oh, I have another idea: could it be that you're also turning some optimization on when UBSan is enabled? Note that the operator new/operator delete pair is elidable in each of these tests, and Clang will remove the calls when compiling with optimizations enabled.</span><br><div><span style="font-size:12.8px"><br></span></div></span><div><span style="font-size:12.8px">That's it. The UBSAN tests build w/ -O2.</span></div></div></blockquote><div><br></div><div>OK. You should be able to get the tests to pass by escaping the allocation somehow. Try changing the type of the x variable to 'B *volatile'.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class="HOEnZb"><font color="#888888"><div><span style="font-size:12.8px">/Eric</span></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 14, 2016 at 4:18 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"><div class="gmail_extra"><div class="gmail_quote">Oh, I have another idea: could it be that you're also turning some optimization on when UBSan is enabled? Note that the operator new/operator delete pair is elidable in each of these tests, and Clang will remove the calls when compiling with optimizations enabled.</div><div><div class="m_179183551003436053h5"><div class="gmail_quote"><br></div><div class="gmail_quote">On Fri, Oct 14, 2016 at 2:38 PM, Eric Fiselier via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</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 may not be replacing the function, but it is doing something weird at the codegen level. I looked into this a while ago but never sorted it out.<div><br></div><div>Either way I'll clarify the comments and add the missing reset() calls. Unfortunately the tests still fail in the same way.</div></div><div class="m_179183551003436053m_-210876384759712623HOEnZb"><div class="m_179183551003436053m_-210876384759712623h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 14, 2016 at 11:49 AM, 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"><div class="gmail_extra"><div class="gmail_quote"><span>On Fri, Oct 14, 2016 at 12:49 AM, Eric Fiselier via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ericwf<br>
Date: Fri Oct 14 02:49:15 2016<br>
New Revision: 284210<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=284210&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=284210&view=rev</a><br>
Log:<br>
XFAIL  aligned allocation test failures with UBSAN<br>
<br>
Modified:<br>
    libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.array/delete_<wbr>align_val_t_replace.pass.cpp<br>
    libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.array/new_ali<wbr>gn_val_t_nothrow_replace.pass.<wbr>cpp<br>
    libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.single/delete<wbr>_align_val_t_replace.pass.cpp<br>
    libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.single/new_al<wbr>ign_val_t_nothrow_replace.pass<wbr>.cpp<br>
<br>
Modified: libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.array/delete_<wbr>align_val_t_replace.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp?rev=284210&r1=284209&r2=284210&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/test/std/la<wbr>nguage.support/support.dynamic<wbr>/new.delete/new.delete.array/d<wbr>elete_align_val_t_replace.pass<wbr>.cpp?rev=284210&r1=284209&r2=2<wbr>84210&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.array/delete_<wbr>align_val_t_replace.pass.cpp (original)<br>
+++ libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.array/delete_<wbr>align_val_t_replace.pass.cpp Fri Oct 14 02:49:15 2016<br>
@@ -17,6 +17,9 @@<br>
 // None of the current GCC compilers support this.<br>
 // XFAIL: gcc-4, gcc-5, gcc-6<br>
<br>
+// UBSAN replaces certain new/delete functions which makes this test fail<br></blockquote><div><br></div></span><div>I don't think that's the problem; the UBSan runtime doesn't replace any functions. Instead...</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+// XFAIL: ubsan<br>
+<br>
 #include <new><br>
 #include <cstddef><br>
 #include <cstdlib><br>
@@ -58,24 +61,24 @@ struct alignas(std::max_align_t) B {};<br>
 int main()<br>
 {<br></blockquote><div><br></div></span><div>I think you're missing a call to reset() here. It looks like the sanitizer runtimes happen to call 'operator new' before entering main.</div><div><div class="m_179183551003436053m_-210876384759712623m_7972499329444719700h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     {<br>
-        B *x = new B;<br>
+        B *x = new B[2];<br>
         assert(0 == unsized_delete_called);<br>
         assert(0 == unsized_delete_nothrow_called)<wbr>;<br>
         assert(0 == aligned_delete_called);<br>
<br>
-        delete x;<br>
+        delete [] x;<br>
         assert(1 == unsized_delete_called);<br>
         assert(0 == unsized_delete_nothrow_called)<wbr>;<br>
         assert(0 == aligned_delete_called);<br>
     }<br>
     reset();<br>
     {<br>
-        A *x = new A;<br>
+        A *x = new A[2];<br>
         assert(0 == unsized_delete_called);<br>
         assert(0 == unsized_delete_nothrow_called)<wbr>;<br>
         assert(0 == aligned_delete_called);<br>
<br>
-        delete x;<br>
+        delete [] x;<br>
         assert(0 == unsized_delete_called);<br>
         assert(0 == unsized_delete_nothrow_called)<wbr>;<br>
         assert(1 == aligned_delete_called);<br>
<br>
Modified: libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.array/new_ali<wbr>gn_val_t_nothrow_replace.pass.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp?rev=284210&r1=284209&r2=284210&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/test/std/la<wbr>nguage.support/support.dynamic<wbr>/new.delete/new.delete.array/n<wbr>ew_align_val_t_nothrow_replace<wbr>.pass.cpp?rev=284210&r1=284209<wbr>&r2=284210&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.array/new_ali<wbr>gn_val_t_nothrow_replace.pass.<wbr>cpp (original)<br>
+++ libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.array/new_ali<wbr>gn_val_t_nothrow_replace.pass.<wbr>cpp Fri Oct 14 02:49:15 2016<br>
@@ -13,9 +13,6 @@<br>
<br>
 // UNSUPPORTED: sanitizer-new-delete<br>
<br>
-// TODO Investigate why UBSAN prevents nothrow new from calling our replacement.<br>
-// XFAIL: ubsan<br>
-<br>
 #include <new><br>
 #include <cstddef><br>
 #include <cstdlib><br>
<br>
Modified: libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.single/delete<wbr>_align_val_t_replace.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp?rev=284210&r1=284209&r2=284210&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/test/std/la<wbr>nguage.support/support.dynamic<wbr>/new.delete/new.delete.single/<wbr>delete_align_val_t_replace.pas<wbr>s.cpp?rev=284210&r1=284209&r2=<wbr>284210&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.single/delete<wbr>_align_val_t_replace.pass.cpp (original)<br>
+++ libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.single/delete<wbr>_align_val_t_replace.pass.cpp Fri Oct 14 02:49:15 2016<br>
@@ -17,6 +17,9 @@<br>
 // None of the current GCC compilers support this.<br>
 // XFAIL: gcc-4, gcc-5, gcc-6<br>
<br>
+// UBSAN replaces certain new/delete functions which makes this test fail<br>
+// XFAIL: ubsan<br>
+<br>
 #include <new><br>
 #include <cstddef><br>
 #include <cstdlib><br>
<br>
Modified: libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.single/new_al<wbr>ign_val_t_nothrow_replace.pass<wbr>.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp?rev=284210&r1=284209&r2=284210&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/test/std/la<wbr>nguage.support/support.dynamic<wbr>/new.delete/new.delete.single/<wbr>new_align_val_t_nothrow_replac<wbr>e.pass.cpp?rev=284210&r1=28420<wbr>9&r2=284210&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.single/new_al<wbr>ign_val_t_nothrow_replace.pass<wbr>.cpp (original)<br>
+++ libcxx/trunk/test/std/language<wbr>.support/support.dynamic/new.d<wbr>elete/new.delete.single/new_al<wbr>ign_val_t_nothrow_replace.pass<wbr>.cpp Fri Oct 14 02:49:15 2016<br>
@@ -13,8 +13,6 @@<br>
<br>
 // UNSUPPORTED: sanitizer-new-delete<br>
<br>
-// TODO Investigate why UBSAN prevents nothrow new from calling our replacement.<br>
-// XFAIL: ubsan<br>
<br>
 #include <new><br>
 #include <cstddef><br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>