How do I initialize LLVM's external symbolizer?
Asked Answered
E

4

12

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?

Euripus answered 10/6, 2014 at 16:1 Comment(0)
E
14

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.

Euripus answered 30/8, 2014 at 8:12 Comment(0)
S
3

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 
Sanctimonious answered 29/7, 2014 at 17:16 Comment(0)
V
1

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.

Vestavestal answered 16/3, 2017 at 21:52 Comment(0)
I
0

I received such warning when I run program debug version (compiled with -fsanitize=address) on Linux machine that didn't contain clang installation. The problem disappeared after I installed clang from devtoolset.

Intercom answered 21/12, 2015 at 11:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.