Błażej Czapp
Błażej Czapp

Reputation: 2633

Leak/Address sanitizer in a shared library without LD_PRELOAD

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_PRELOADing for dotnet.

Is there any way to statically link the sanitizer into the shared library (or dynamically without LD_PRELOAD)?

Upvotes: 2

Views: 2119

Answers (1)

yugr
yugr

Reputation: 21954

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 that libasan 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.

The sanitizer outright crashes when LD_PRELOADing for dotnet.

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).

Upvotes: 3

Related Questions