When compiling with -fsanitize=memory
I get WARNING: Trying to symbolize code, but external symbolizer is not initialized!
when running the program. How do I initialize the external symbolizer?
I solved my own problem using MSAN_SYMBOLIZER_PATH=$(which llvm-symbolizer-3.4) ./a.out
. The problem is that Ubuntu postfixes the version number but the binary doesn't know that. Of course you need to use MSAN
instead of ASAN
when using the memory sanitizer.
On my Ubuntu system, the issue is that LLVM's tools are installed under /usr/bin
with version suffixes (like llvm-symbolizer-4.0
), and the sanitizer tools are looking for them without version suffixes.
LLVM also installs its binaries to, e.g., /usr/lib/llvm-4.0/bin
; the tools under /usr/bin
are actually just symlinks. So an easy solution is to add the appropriate /usr/lib/llvm-*/bin
directory to your path when working with sanitizers.
You are supposed to be able to set the ASAN_FILTER environment variable to point at a symbolizer, but I could not get it to work. However, you can redirect stderr into a symbolizer after the fact. You'll still get the warnings about the uninitialized symbolizer, but the filenames and line numbers will be correct.
You can use asan_symbolizer.py as the external symbolizer. After downloading it from that link (to /tmp, for example), invoke your program like so (in bash, for this example):
./myprogram 2>&1 | /tmp/asan_symbolize.py | c++filt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With