<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 1, 2014 at 4:13 PM, Samuel F Antao <span dir="ltr"><<a href="mailto:sfantao@us.ibm.com" target="_blank">sfantao@us.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi Kostya,<div><br></div><div>Thanks for looking into this! Currently the test starts calling the destructor ~C() several times as it were in a infinite loop and it does not return. </div></div></blockquote><div><br></div><div>Aha, I see the problem! </div><div><br></div><div>The test has an intentional bug that asan is supposed to find. </div><div>So, by default and with ASAN_OPTIONS=poison_array_cookie=1 the test should never reach the point where it calls ~C. </div><div>Is this true for you on PPC? </div><div><br></div><div>But then, the test is also executed with ASAN_OPTIONS=poison_array_cookie=0, i.e. the bug is not detected and the execution goes further and tries to execute the DTOR. </div><div>And then yes, on a little-endian machine the DTOR will get executed 10 times, while on a big-endian one it will get executed near-infinite amount of times. </div><div><br></div><div>Does r218841 help? </div><div><br></div><div>--kcc </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>I'll try to explain how do I understand the problem. Just to make sure we are on the same page, I am attaching the instrumented IR that I obtain by running:</div><div><br></div><div>clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -m64 -O3 /home/sfantao/llvm-trunk/llvm-svn.src/projects/compiler-rt/test/asan/TestCases/Linux/new_array_cookie_test.cc -o <a href="http://debug.ir" target="_blank">debug.ir</a> -S -emit-llvm<br></div><div><br></div><div>In this code %x (i32*) and %9 (*i64) alias to %call. When 10 is stored to %x, the way this is reflected in a load from %9 (the ASAN calls use this pointer instead of %x) differs depending on the endianess. Assuming that %9 and %x are 0x00, the memory layout before and after the store in big-endian will be</div><div> </div><div>Addr - Before - After</div><div>0x00 0xZZ 0xZZ</div><div>0x01 0xZZ 0xZZ<br></div><div>0x02 0xZZ 0xZZ<br></div><div>0x03 0xZZ 0x0A<br></div><div>0x04 0xZZ 0xZZ<br></div><div>0x05 0xZZ 0xZZ<br></div><div>0x06 0xZZ 0xZZ<br></div><div>0x07 0xZZ 0xZZ<br></div><div><br></div><div>When a load using %9 is done, I get 0xZZZZZZ0AZZZZZZZZ. In a little-endian machine I would get 0xZZZZZZZZZZZZZZ0A instead, what is probably what you would expect. Then, when the destructor is called, whatever is decoding the size of 'buffer' loads the wrong information (possible zero or a very large number, causing the infinite loop).</div><div><br></div><div>Any hint on how to fix this? I understand some other information is being encoded in the pointers, so it is hard for me to understand whether fixing this for %x would have bad implications in other components of the sanitizer.</div><div><br></div><div>Let me know if you'd like me to provide more information. </div><div><br></div><div>Thanks again!</div><div>Samuel</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-10-01 14:28 GMT-04:00 Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span>:<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Mon, Sep 8, 2014 at 7:00 PM, Samuel F Antao <span dir="ltr"><<a href="mailto:sfantao@us.ibm.com" target="_blank">sfantao@us.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>
<p><font face="sans-serif">Alexey, Alexander,</font><br>
<br>
<font face="sans-serif">Thanks for the suggestions. I tried removing the flag </font><tt><font>SA_NODEFER </font></tt><font face="sans-serif">but it didn't do any good...</font><font face="sans-serif"> I have been digging into the problem with the null_deref test today but I was unable to clearly identify the problem. I suspect that it was either a bug with the calling convention/unwinding that lead to the flags() pointer to get corrupted. It is also possible that it was related with endianess issues caused by some bug in the pointer arithmetic inserted by the sanitizer code (there are many type and bit casts which makes hard to follow the references). I decided to upgrade the compiler I was using to build clang which made the problem with this testcase to go away (!).</font><br>
<br>
<font face="sans-serif">Nevertheless, I still got problems in other testcases that may be potentially related with the problem I was getting before. E.g., in the new_array_cookie_test I am getting an infinite loop in the destructor of the array (delete [] operator). I noticed that the references passed to __asan_poison_cxx_array_cookie and __asan_load_cxx_array_cookie were pointing to values differing in the 4 most significant bytes, which made me suspect that the problem is related with endianess. I am reproducing part of the IR generated for this test:</font></p></div></blockquote></span><div>[I am sorry, I've missed this thread. Don't hesitate to ping me if I don't respond in 1-2 days. ]</div><div> </div><div>This is a new test for new functionality, currently present in clang's asan, not in GCC. </div><div>We never tried it on big-endian machines. </div><div><div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><p><br>
<br>
<font face="sans-serif"> store i64 %0, i64* %9, align 8, !dbg !35, !nosanitize !2</font><br>
<font face="sans-serif"> call void @__asan_poison_cxx_array_cookie(i64* %9), !dbg !35</font><br>
<font face="sans-serif"> %10 = getelementptr inbounds i8* %call, i64 8, !dbg !35</font><br>
<font face="sans-serif"> %11 = bitcast i8* %10 to %struct.C*, !dbg !35</font><br>
<font face="sans-serif"> call void @llvm.dbg.value(metadata !{%struct.C* %11}, i64 0, metadata !23), !dbg !36</font><br>
<font face="sans-serif"> %x = bitcast i8* %call to i32*, !dbg !37</font><br>
<font face="sans-serif"> %12 = ptrtoint i32* %x to i64, !dbg !37</font><br>
<font face="sans-serif"> %13 = lshr i64 %12, 3, !dbg !37</font><br>
<font face="sans-serif"> %14 = add i64 %13, 2199023255552, !dbg !37</font><br>
<font face="sans-serif"> %15 = inttoptr i64 %14 to i8*, !dbg !37</font><br>
<font face="sans-serif"> %16 = load i8* %15, !dbg !37</font><br>
<font face="sans-serif"> %17 = icmp ne i8 %16, 0, !dbg !37</font><br>
<font face="sans-serif"> br i1 %17, label %18, label %24, !dbg !37, !prof !38</font><br>
<br>
<font face="sans-serif">; <label>:18 ; preds = %entry</font><br>
<font face="sans-serif"> %19 = and i64 %12, 7, !dbg !37</font><br>
<font face="sans-serif"> %20 = add i64 %19, 3, !dbg !37</font><br>
<font face="sans-serif"> %21 = trunc i64 %20 to i8, !dbg !37</font><br>
<font face="sans-serif"> %22 = icmp sge i8 %21, %16, !dbg !37</font><br>
<font face="sans-serif"> br i1 %22, label %23, label %24</font><br>
<br>
<font face="sans-serif">; <label>:23 ; preds = %18</font><br>
<font face="sans-serif"> call void @__asan_report_store4(i64 %12), !dbg !37</font><br>
<font face="sans-serif"> call void asm sideeffect "", ""()</font><br>
<font face="sans-serif"> unreachable</font><br>
<br>
<font face="sans-serif">; <label>:24 ; preds = %18, %entry</font><br>
<font face="sans-serif"> store i32 10, i32* %x, align 4, !dbg !37, !tbaa !39</font><br>
<font face="sans-serif"> %25 = call i64 @__asan_load_cxx_array_cookie(i64* %9), !dbg !44</font><br>
<br>
<font face="sans-serif">In this code, %9 and %x alias but have different types (i64* and i32*), which makes the code in 'store i32 10, i32* %x, align 4, !dbg !37, !tbaa !39' to produce different results in machines with different endianess. In a big-endian machine the value 10 is written to the 4 most-significant bytes of the memory referenced by %9. </font></p></div></blockquote><div><br></div></div></div><div>How does the test behave on PPC? </div><div><br></div><div><br></div><div>--kcc <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div><p><br>
<br>
<font face="sans-serif">As I mentioned before, I don't know the sanitizer implementation well so it is possible I may be missing something. Can anyone shed some light on this?</font><br>
<br>
<font face="sans-serif">Thanks again!</font><br>
<font face="sans-serif">Samuel</font><br>
<br>
<img width="16" height="16" src="cid:1__=0ABBF7DDDF9B07C78f9e8a93df938@us.ibm.com" border="0" alt="Inactive hide details for Alexander Potapenko ---09/05/2014 02:06:43 AM---Note that I've set the SA_NODEFER flag for the SEGV h"><font color="#424282" face="sans-serif">Alexander Potapenko ---09/05/2014 02:06:43 AM---Note that I've set the SA_NODEFER flag for the SEGV handler in the ASan runtime only a couple of day</font><br>
<br>
<font size="1" color="#5F5F5F" face="sans-serif">From: </font><font size="1" face="sans-serif">Alexander Potapenko <<a href="mailto:glider@google.com" target="_blank">glider@google.com</a>></font><br>
<font size="1" color="#5F5F5F" face="sans-serif">To: </font><font size="1" face="sans-serif">Alexey Samsonov <<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Cc: </font><font size="1" face="sans-serif">Samuel F Antao/Watson/IBM@IBMUS, Clang Developers List <<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>>, LLVM Dev <<a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a>></font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Date: </font><font size="1" face="sans-serif">09/05/2014 02:06 AM</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Subject: </font><font size="1" face="sans-serif">Re: [cfe-dev] Address sanitizer regression test failures for PPC64 targets</font><br>
</p><hr width="100%" size="2" align="left" noshade style="color:rgb(128,145,165)"><div><div><br>
<br>
<br>
<tt><font>Note that I've set the SA_NODEFER flag for the SEGV handler in the<br>
ASan runtime only a couple of days ago.<br>
Not sure that could've affected this test though; without that flag<br>
the second SEGV would've simply crashed the program. But you can try<br>
removing the flag from<br>
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc and<br>
see if that makes any difference.<br>
<br>
HTH,<br>
Alex<br>
<br>
On Fri, Sep 5, 2014 at 5:26 AM, Alexey Samsonov <<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>> wrote:<br>
> +Bill Schmidt<br>
><br>
> On Thu, Sep 4, 2014 at 5:39 PM, Samuel F Antao <<a href="mailto:sfantao@us.ibm.com" target="_blank">sfantao@us.ibm.com</a>> wrote:<br>
>><br>
>> Hi all,<br>
>><br>
>> I have been experiencing the failure of the address sanitizer regression<br>
>> tests for a PPC64 target (Power7 machine). My understanding is that most of<br>
>> the failures are related with the fact the stack is not being dumped.<br>
>><br>
>> I tried to understand what might be wrong and started by looking into the<br>
>> null_deref.cc test as it hangs during the test run. I observe that after<br>
>> the detection of the faulty memory access it receives a SEGV after entering<br>
>> ReportSIGSEGV() more precisely when it gets to the __intercept_strlen() and<br>
>> tries to access flags()->replace_str. The caller of __intercept_strlen() is<br>
>> get_cie_encoding() from libgcc (version 4.8.2 in my system).<br>
>><br>
>> As I am not familiar with the sanitizer implementation, I was wondering if<br>
>> this is an expected failure for PPC targets due to some incomplete<br>
>> implementation, an unexpected bug, or due to some misconfiguration in the<br>
>> Clang/LLVM build for PPC targets.<br>
>><br>
>> Has anyone experienced a similar issue?<br>
><br>
><br>
> Sanitizer used to work on PPC at some point, but currently it fails on most<br>
> of the tests from "check-asan" test suite on the PowerPC buildbot<br>
> (</font></tt><tt><font><a href="http://lab.llvm.org:8011/builders/sanitizer-ppc64-linux1" target="_blank">http://lab.llvm.org:8011/builders/sanitizer-ppc64-linux1</a></font></tt><tt><font>).<br>
> I can't really diagnose the issue from your description. flags() is just a<br>
> pointer to a global variable, so I don't see why access to<br>
> flags()->replace_str will segfault.<br>
><br>
>><br>
>><br>
>><br>
>> Thanks in advance!<br>
>> Samuel<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-dev mailing list<br>
>> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
>> </font></tt><tt><font><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></font></tt><tt><font><br>
>><br>
><br>
><br>
><br>
> --<br>
> Alexey Samsonov<br>
> <a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a><br>
><br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
> </font></tt><tt><font><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></font></tt><tt><font><br>
><br>
<br>
<br>
<br>
-- <br>
Alexander Potapenko<br>
Software Engineer<br>
Google Moscow<br>
<br>
</font></tt><br>
</div></div><p></p></div>
<br></div></div><span>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></span></blockquote></div><br></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div></div></div><br></div>
</blockquote></div><br></div></div>