<div dir="ltr">What does "ghc -Wall -Icsrc -optc "-fsanitize=address" -optc -g -lasan $+ -o $@" do? <div>I suspect it performs an optimized compilation (e.g. equivalent of clang's -O2). </div><div>That would explain why you don't see a bug report: </div><div>the .c code is too simple and the buggy access is optimized away. Take a look at the assembly: </div><div><div>0000000000405eba <dodgy_addition>:</div><div> 405eba: 53 push %rbx</div><div> 405ebb: 48 8d 1c 37 lea (%rdi,%rsi,1),%rbx</div><div> 405ebf: 48 83 fb 0a cmp $0xa,%rbx</div><div> 405ec3: 76 0a jbe 405ecf <dodgy_addition+0x15></div><div> 405ec5: bf 00 02 48 00 mov $0x480200,%edi</div><div> 405eca: e8 f1 cc ff ff callq 402bc0 <puts@plt></div><div> 405ecf: 48 89 d8 mov %rbx,%rax</div><div> 405ed2: 5b pop %rbx</div><div> 405ed3: c3 retq </div></div><div><br></div><div><br></div><div>Now, if I insert enough printfs to convince the compiler to keep the buggy access, it's still hard for asan to find it, </div><div>because you dereference an element # 2065 of an array of ten elements. </div><div>This simply goes too far from bounds (remember: asan relies on redzones to catch buffer overflows).</div><div><br></div><div>If I modify the code like this: </div><div><div> printf("ZZZ %p %zd\n", array, sum % 11);</div><div> array [sum- 2055] = sum ;</div></div><div><br></div><div>I get a nice </div><div><div>==35617== ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffeccdd9b00 at pc 0x405fcd bp 0x7ffeccdd9a80 sp 0x7ffeccdd9a78</div><div>WRITE of size 8 at 0x7ffeccdd9b00 thread T0</div></div><div><br></div><div>--kcc </div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 6, 2017 at 11:33 PM, Erik de Castro Lopo <span dir="ltr"><<a href="mailto:mle+cl@mega-nerd.com" target="_blank">mle+cl@mega-nerd.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="">Kostya Serebryany wrote:<br>
<br>
> I don't know anything about haskell, but if you post a minimal reproducer<br>
> here<br>
> we *may* be able to help.<br>
<br>
</span>Its just so happens that I do have something here:<br>
<br>
<a href="https://github.com/erikd-ambiata/haskell-sanitize" rel="noreferrer" target="_blank">https://github.com/erikd-<wbr>ambiata/haskell-sanitize</a><br>
<br>
The Readme should have all the information you need. Any problems,<br>
please let mw know.<br>
<div class="HOEnZb"><div class="h5"><br>
Cheers,<br>
Erik<br>
--<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
Erik de Castro Lopo<br>
<a href="http://www.mega-nerd.com/" rel="noreferrer" target="_blank">http://www.mega-nerd.com/</a><br>
</div></div></blockquote></div><br></div>