Meaningful Stack Traces for Address Sanitizer in Gcc

Meaningful stack traces for address sanitizer in GCC

This is what is working for me:

  • Make sure you have installed llvm (including llvm-symbolizer).
  • Export the following variable

    export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer

    (replace with your correct path to the llvm-symbolizer command).

  • Now run your executable (a.out for now) as

    ASAN_OPTIONS=symbolize=1 a.out

VC2019 address sanitizer no symbolic stack trace 64bit

The problem was that I didn't call vcvars64.bat (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat)

I did set all library paths manually and also did set the PATH to the llvm-symbolizer.exe ( located in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64 ) but apparently the clang_rt.asan_dynamic... libs seem to look at another environment variable to perform the symbolizing.

It turned out after trial and error that for 64bit the symbolizing looks additionally in the PATH and searches msdia140.dll (found in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64 in my VC installation ).

The summary is that the PATH need to point to the directories containing llvm-symbolizer.exe and msdia140.dll in order to let the symbolizer work correctly.

2nd solution: I discovered that there is also the ability to override the location of llvm-symbolizer.exe with the env variable ASAN_SYMBOLIZER_PATH (this variable isn't set in the vcvars64.bat call chain). This overrides the location found in the PATH.

set ASAN_SYMBOLIZER_PATH=C:\Users\leo\llvm-symbolizer.exe would set a custom symbolizer: note that the name needs to be llvm-symbolizer.exe !

ASAN_SYMBOLIZER_PATH can also point to a directory name instead of the executable (the runtime tries to find then llvm-symbolizer.exe in this directory) .

And: still the PATH to msdia140.dll is needed to ensure proper symbolizing.

address sanitizer (-fsanitize=address) works with tcmalloc?

Developers usually discourage from combining ASan with non-Glibc allocators (e.g. here) but theoretically there shouldn't be much difference - ASan is capable of intercepting any memory allocator on Linux (via symbol interposition).

GCC Address Sanitizer - blacklisting library functions (specifically boost::test)

If the sanitize-blacklist is not available, but you have access to the source code, you can exclude individual functions from being sanitized using a function attribute:

It is supported by Clang (3.3+) and GCC (4.8+). You can define the following macro:

#if defined(__clang__) || defined (__GNUC__)
# define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else
# define ATTRIBUTE_NO_SANITIZE_ADDRESS
#endif
...
ATTRIBUTE_NO_SANITIZE_ADDRESS
void ThisFunctionWillNotBeInstrumented() {...}

See this page for more details.

Interpreting ASAN output : Unknown Crash

I was able to solve problem with this link.

apt-get install llvm
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4
ASAN_OPTIONS=symbolize=1 ./selftls 1 crash-packet

Thanks.



Related Topics



Leave a reply



Submit