<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 11, 2016 at 11:17 PM, Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Hi Sean,<br>
<br>
Sean Silva wrote:<br>
><br></span><span class="">
>     But asan won't catch problems (insofar I understand how it works) if<br>
>     the free'ed BasicBlock is used as a key in a DenseMap or something --<br>
>     if another BasicBlock gets allocated to the same location we'll end up<br>
>     returning bad cached results.<br>
><br>
><br>
> ASan's allocator is specifically hardened against reusing memory, which<br>
> mitigates this, but I'm not sure by how much (but I think by a<br>
> significant amount).<br>
<br></span>
Do you mean it will re-use memory less often?  Won't that just hide<br>
the bug above?  If anything, I don't want ASan to "mitigate" bugs, I<br>
want it to make the bug trigger more often. :)<br></blockquote><div><br></div><div>ASan's reuses it less often, but keeps it poisoned so that dangling pointers get caught. This makes it less likely that re-use will cause invalid analysis results. BUT it makes it more likely that when we access a dangling pointer, it falls into a poisoned heap area. So the net result is that it catches dangling pointers better.</div><div><br></div><div>Or to put it another way, the "heap slot reuse causes invalid analysis results" situation is actually a subset of "we access a dangling pointer" which is what we really want to catch (I mean "dangling" in a sense that a pointer stays "dangling" even if its heap slot is reused). By avoiding reuse of heap slots, the dangling pointer is more likely to be in a heap slot that ASan is keeping poisoned and not reusing (hence it can detect the error).</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
(Or did I just re-state what you were saying?)<span class="HOEnZb"><font color="#888888"><br>
<br>
-- Sanjoy<br>
</font></span></blockquote></div><br></div></div>