<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 11/3/12 4:06 AM, Kostya Serebryany
wrote:<br>
</div>
<blockquote
cite="mid:CAN=P9pip8VsGc+eHt=T-nVBzBba=y301Hfq1NeEq-p-hEb+MkQ@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div style="font-family: arial, helvetica, sans-serif; font-size:
10pt">Also note that this is not the kind of bug for which asan
is good.
<div>If we are dereferencing an uninitialized pointer, there is
a high chance that the program will SEGV w/o any tool.</div>
<div>If we are unlucky and the garbage is accidentally equal to
some valid address, asan will not catch it either. </div>
<div>Valgrind (and work-in-progress MemorySanitizer) will catch
this. <br>
</div>
</div>
</blockquote>
<br>
Kostya, I think you're misreading the test case. He's storing a
64-bit value into a 32-bit pointer on a 32-bit platform. The
pointer value in f() is initialized (at least in the case where the
compiler's not optimizing away things due to undefined behavior).
The problem is that a 64-bit store doesn't fit into a 32-bit
pointer.<br>
<br>
ASan is catching that when the load isn't optimized away, and I've
verified that mainline SAFECode does as well. It also appears that
SAFECode finds the error when the noinline attribute is removed, but
I think that's a bug in how we integrated SAFECode into Clang (the
store should be optimized away by the LLVM optimizations, but it
isn't).<br>
<br>
Rafael, for now, if you want to get more pedantic behavior out of
ASan and SAFECode, you might want to try reducing the optimization
level. However, your test case brings up a good point: should there
be an option to clang that makes tools like ASan and SAFECode more
or less pedantic (either by reducing optimization or making checks
more picky)? It might make a good question at our BoF session next
week. :)<br>
<br>
-- John T.<br>
<br>
<br>
<blockquote
cite="mid:CAN=P9pip8VsGc+eHt=T-nVBzBba=y301Hfq1NeEq-p-hEb+MkQ@mail.gmail.com"
type="cite">
<div style="font-family: arial, helvetica, sans-serif; font-size:
10pt">
<div><br>
</div>
<div>--kcc <br>
<br>
<div class="gmail_quote">On Sat, Nov 3, 2012 at 5:38 AM, Eli
Friedman <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@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 class="im">On Fri, Nov 2, 2012 at 6:27 PM, Rafael
Espíndola<br>
<<a moz-do-not-send="true"
href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>>
wrote:<br>
> I just tried asan on an optimized 32 bit build of<br>
> -------------------------------------<br>
> #include <stdint.h><br>
> __attribute__((noinline))<br>
> void f(uint64_t *p) {<br>
> *p = 42;<br>
> }<br>
> int main() {<br>
> void *p;<br>
> f((uint64_t*)&p);<br>
> }<br>
> ------------------------------------<br>
><br>
> and it correctly catches the invalid access. If I
comment the<br>
> attribute, the optimizers find and exploit the
undefined behavior and<br>
> asan fails to report it. Is this the expected
behavior? Is this<br>
> something that needs -fcatch-undefined-behavior
instead?<br>
<br>
</div>
For performance reasons, asan runs at the end of the
optimization<br>
pipeline, so it doesn't check loads which get removed by
the IR<br>
optimizers.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Eli<br>
</font></span>
<div class="HOEnZb">
<div class="h5"><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a moz-do-not-send="true"
href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>
<a moz-do-not-send="true"
href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a moz-do-not-send="true"
href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev"
target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>