www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - dsymutil on OSX

Hi all,
   I have spent almost two hours figuring out why I didn't see 
line numbers in the stack traces output by AddressSanitizer. Or: 
I _am_ seeing them when running the sanitized binary manually, 
but do not see line numbers when running an automated (lit-based) 
test.
Finally, it turns out that llvm-symbolizer does not show line 
numbers in stack traces for our binaries unless dsymutil is run 
on the executable. AddressSanitizer automatically searches the 
path for llvm-symbolizer, and our lit-based testsuite adds the 
llvm bin dir to the path, so it will find llvm-symbolizer. When 
running the sanitized binary manually, llvm-symbolizer was not on 
the path, and apparently another symbolizing method is used that 
_does_ show line numbers.
There is a note about this in Address Sanitizer documentation... 
:(

See: https://github.com/google/sanitizers/issues/207

Clang runs dsymutil (depending on what kind of build is done), to 
prevent exactly these kinds of problems. Running dsymutil makes 
linking slower, so I don't know whether we want to add this or 
not.
What do you think?

Mainly I want to tell you that if you are seeing missing 
debuginfo issues, you should check whether they are resolved 
after running dsymutil on the executable.

- Johan


Off topic:
I also found that OSX only supports Dwarf version 2 (instead of 
our higher default):
https://github.com/rust-lang/rust/issues/11352
But I see in Clang's source that since OSX 10.11 (El Capitan, the 
one I am on, lagging behind one version), Dwarf 4 is supported.
Jul 19 2017