title: How do I get line numbers in the debug output with clang's -fsanitize=address?
body: <p>I am trying to debug a memory error detected by <code>clang</code> with <code>asan</code>, but missed by <code>valgrind</code>. But I cannot get my <code>clang</code> built binary to give me any useful debugging information. I can demonstrate this with a short test program:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main(void)
  {
      char *a = malloc(8);
      memset(a, 0, 9);
      free(a);
      return 0;
  }
  </code></pre>
  
  <p>(Obviously this error <em>will</em> be picked up by <code>valgrind</code>, it's purely to show the problem with <code>clang</code>.)</p>
  
  <p>I compile it with Clang 3.4-1ubuntu1 like so:</p>
  
  <pre><code>clang -fsanitize=address -fno-sanitize-recover -o test -O0 -g test.c
  </code></pre>
  
  <p>Sure enough, <code>./test</code> aborts and I see some debugging info:</p>
  
  <pre><code>==3309==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000eff8 at pc 0x43e950 bp 0x7fff168724f0 sp 0x7fff168724e8
  WRITE of size 9 at 0x60200000eff8 thread T0
      #0 0x43e94f (/home/jason/Code/astest/test+0x43e94f)
      #1 0x7faa43c47de4 (/lib/x86_64-linux-gnu/libc.so.6+0x21de4)
      #2 0x43e6ac (/home/jason/Code/astest/test+0x43e6ac)
  0x60200000eff8 is located 0 bytes to the right of 8-byte region [0x60200000eff0,0x60200000eff8)
  allocated by thread T0 here:
      #0 0x42cc25 (/home/jason/Code/astest/test+0x42cc25)
      #1 0x43e874 (/home/jason/Code/astest/test+0x43e874)
      #2 0x7faa43c47de4 (/lib/x86_64-linux-gnu/libc.so.6+0x21de4)
  </code></pre>
  
  <p>But what I really want to know are the line numbers where the error occurred, and where the memory was allocated.</p>
  
  <p>How do I get this information from <code>clang</code>+<code>asan</code>?</p>