When I compile with -fsanitize=address
, GCC/Clang implicitly make use of an ASAN dynamic library which provides runtime support for ASAN. If your built library is dynamically loaded by another application, it is necessary to set LD_PRELOAD
to include this dynamic library, so that it gets run at application start up time.
It is often not obvious which copy of libasan.so
GCC/Clang expects to use, because there may be multiple copies of ASAN on your system (if you have multiple compilers installed.) Is there a reliable way to determine the location of the shared library you need to load?
You can use
-print-file-name
flag:You could also extract libasan path from the library itself via
ldd
: