<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 10, 2016 at 7:30 AM, Hahnfeld, Jonas <span dir="ltr"><<a href="mailto:Hahnfeld@itc.rwth-aachen.de" target="_blank">Hahnfeld@itc.rwth-aachen.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> cfe-dev [mailto:<a href="mailto:cfe-dev-bounces@lists.llvm.org" target="_blank">cfe-dev-bounces@lists.llvm.org</a>] <b>On Behalf Of </b>Hahnfeld, Jonas via cfe-dev<br><b>Sent:</b> Wednesday, February 10, 2016 7:43 AM<br><b>To:</b> Alexey Samsonov<br><b>Cc:</b> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a></span></p><div><div class="h5"><br><b>Subject:</b> Re: [cfe-dev] Sanitizer test failures when switching to libc++ by default<u></u><u></u></div></div><p></p></div></div><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div class="h5"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Alexey Samsonov [<a href="mailto:vonosmas@gmail.com" target="_blank">mailto:vonosmas@gmail.com</a>] <br><b>Sent:</b> Wednesday, February 10, 2016 1:54 AM<br><b>To:</b> Hahnfeld, Jonas<br><b>Cc:</b> Kostya Serebryany; <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><b>Subject:</b> Re: [cfe-dev] Sanitizer test failures when switching to libc++ by default<u></u><u></u></span></p></div></div><p class="MsoNormal"><u></u> <u></u></p></div></div><div><div><p class="MsoNormal"><u></u> <u></u></p><div><div><div class="h5"><p class="MsoNormal">On Sat, Feb 6, 2016 at 1:33 AM, Hahnfeld, Jonas <<a href="mailto:Hahnfeld@itc.rwth-aachen.de" target="_blank">Hahnfeld@itc.rwth-aachen.de</a>> wrote:<u></u><u></u></p><div><div><p class="MsoNormal"> <u></u><u></u></p><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Alexey Samsonov [mailto:<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>] <br><b>Sent:</b> Friday, February 05, 2016 11:05 PM<br><b>To:</b> Kostya Serebryany<br><b>Cc:</b> Hahnfeld, Jonas; <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><b>Subject:</b> Re: [cfe-dev] Sanitizer test failures when switching to libc++ by default</span><u></u><u></u></p></div></div><p class="MsoNormal"> <u></u><u></u></p><div><div><div><p class="MsoNormal">On Fri, Feb 5, 2016 at 11:11 AM, Kostya Serebryany via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">On Fri, Feb 5, 2016 at 6:21 AM, Hahnfeld, Jonas via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p><p class="MsoNormal">Hi all,<br><br>I'm currently looking into (optionally) switching the default C++ stdlib to<br>libc++ (see <a href="http://reviews.llvm.org/D15920" target="_blank">http://reviews.llvm.org/D15920</a> which hasn't received a review so<br>far)<br>I've resolved all regression test failures in clang which are now passing<br>cleanly.<br><br>I'm now investigating the failing sanitizer tests in compiler-rt, here's<br>what I got so far:<br> - two tests use -static-libstdc++ which obviously needs a -stdlib=libstdc++<br>(asan/TestCases/throw_invoke_test.cc and tsan/static_init6.cc)<u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Makes sense. <u></u><u></u></p></div><div><p class="MsoNormal">I wonder if we can also use -static-libc++ for these tests<u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">At least in my build there is not static version of libc++… I think this isn’t built by default but I haven’t yet searched for an opt-in.</span><u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><p class="MsoNormal"> - tsan builds an instrumented version of libc++ and adds their headers.<br>This leads to errors with default C headers which are #include_next'd in<br>libc++. These #include_next then find the headers of the "normal" libc++<br>which in turn instantly return because of the header guards. Therefore basic<br>functions like printf aren't defined.<br>Solution: Pass -nostdinc++ to disable the headers of the "normal" libc++<u></u><u></u></p></blockquote><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">emm, probably. <u></u><u></u></p></div></div></div></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Just to clarify: do you want to pass it to TSan lit tests? How would you ensure that<u></u><u></u></p></div><div><p class="MsoNormal">we'll still pick up C++ standard library headers when tests are run with Clang configured<u></u><u></u></p></div><div><p class="MsoNormal">to use libstdc++?<u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I’m planning on passing it in test/tsan/lit.cfg around line 57. Those flags are only applied if an instrumented version of libcxx is available and there is an explicit definition of the header include path, so this should work.</span><u></u><u></u></p></div></div></div></div></div></div></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">I see. Yes, probably -nostdinc++ would work in this case.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><div><div><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div><div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><div><div><div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><p class="MsoNormal"> - lsan completely fails with libc++, I had to generally pass<br>-stdlib=libstdc++ - is this known and possibly still work in progress?<u></u><u></u></p></blockquote><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">This is not known to me. What are the symptoms? <u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">“LeakSanitizer has encountered a fatal error†on all C++ tests. This is fixed when building the tests with “-stdlib=libstdc++â€, everything else still built with libc++…</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I also can’t debug with gdb because the errors seems to not occur inside a debugger :-( is there any special trick with the sanitizers inside a debugger that I have not found yet?</span><u></u><u></u></p></div></div></div></div></blockquote></div></div></div></div></div></div></blockquote><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">LSan uses ptrace to stop the program and list all its threads, the same as GDB. So, LSan is sadly special in this case. You can try to gain more insight into what's happening by running the binary<u></u><u></u></p></div></div></div><div><div><div class="h5"><p class="MsoNormal">with smth. like LSAN_OPTIONS=verbosity=1:log_pointers=1:log_threads=1 (apart from LSAN_OPTIONS specified in each lit test case).<u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks for the hint, I will try and see whether I can get some reliable information…<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p></div></div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">--<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Ok, so here are my findings so far:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">verbosity=1 revealed the output “Tracer caught signal 11: […]â€<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">So I disabled the signal handler and the core-file told me that it died when dereferencing the first TLS address in “ScanRangeForPointers()†in lib/lsan/lsan_common.cc.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">(this also explains the behavior within gdb: It then can’t attach to the thread and therefore doesn’t  crash on scanning TLS)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">For me it looks like “ThreadSelf()†in lib/sanitizer_common/sanitizer_linux_libcdep.cc reports a wrong address…<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I can reproduce this with a small C++ program that only contains an empty main: It crashes with –fsanitize=leak –stdlib=libc++ and works fine with –stdlib=libstdc++.</span></p></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>... but if there's only main() then you don't have threads except for the main thread. Or does LSan crash when trying to access TLS of a main thread?</div><div>That's weird anyway. It may be the case that libc++ initializers use TLS differently than libstdc++ ones.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div><div><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Information on my system: x86-64, Scientific Linux 6.6 -> glibc 2.12<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It seems to work with libc++ on CentOS 7, but then why is libstdc++ also working on SL6?</span></p></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>I don't know. Is there a difference in what ThreadSelf() and (in particular) ThreadDescriptorSize() report on these platforms? This code is really fragile, and it can easily fail for certain versions or forks of glibc.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div><div><div><div class="h5"><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><div><div><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div><div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><div><div><div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><p class="MsoNormal" style="margin-bottom:12.0pt"><br>Greetings,<br>Jonas<br><br>--<br>Jonas Hahnfeld, MATSE-Auszubildender<br><br>IT Center<br>Group: High Performance Computing<br>Division: Computational Science and Engineering<br>RWTH Aachen University<br>Seffenter Weg 23<br>D 52074 Aachen (Germany)<br><a href="mailto:Hahnfeld@itc.rwth-aachen.de" target="_blank">Hahnfeld@itc.rwth-aachen.de</a><br><a href="http://www.itc.rwth-aachen.de" target="_blank">www.itc.rwth-aachen.de</a><br><br><br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><u></u><u></u></p></blockquote></div><p class="MsoNormal"> <u></u><u></u></p></div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><u></u><u></u></p></blockquote></div><p class="MsoNormal"><br><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p></div><p class="MsoNormal">-- <u></u><u></u></p><div><div><p class="MsoNormal">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a><u></u><u></u></p></div></div></div></div></div></div></div></blockquote></div></div></div><p class="MsoNormal"><br><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">-- <u></u><u></u></p><div><div><p class="MsoNormal">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a><u></u><u></u></p></div></div></div></div></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></div>