I'm looking to use Clang's leak/address sanitizer on my shared library, which is loaded from JVM or dotnet
(Linux) at runtime, so I can't recompile the binary.
Using LD_PRELOAD
makes for a very noisy output, a lot (presumably false positive?) leaks get reported from the JVM itself. The sanitizer outright crashes when LD_PRELOAD
ing for dotnet
.
Is there any way to statically link the sanitizer into the shared library (or dynamically without LD_PRELOAD
)?
First thing first, you can not statically link sanitizer runtime libs into your library. It has to be preloaded to intercept std allocator (
malloc
, etc.) and would malfunction otherwise (there's a special check at Asan startup that ensures thatlibasan
was preloaded).Noisy output in JVM may well be legitimate errors. Using
LD_PRELOAD
makes for a very noisy output, a lot (presumably false positive?) leaks get reported from the JVM itself.Is it a real crash or diagnosed memory error? Crash can be reported in Asan tracker. Memory error should be reported to dotnet project but you can still continue execution after it using continue-after-error mode (grep for "continue-after-error" in Asan FAQ).