user1233963
user1233963

Reputation: 1490

How to get ASAN to ignore child process?

I'm trying to run my application with ASAN enabled to search for leaks and other errors but, since I'm using popen inside the application, sanitizer reports child process errors as well it seems (which I really do not care about and are confusing).

Is there a way to make it ignore child processes ?

My environment is: Fedora 26, gcc 7.3.1, libasan 7.3.1-6

Upvotes: 3

Views: 1450

Answers (1)

yugr
yugr

Reputation: 21964

I suspect that you are using LD_PRELOAD=libasan.so which will cause Asan runtime to be preloaded to child processes. This will cause some limited form of sanitization because runtime will intercept and sanitize calls to standard libc functions like malloc or memcpy.

There is no builtin way to disable this inside Asan so your best bet would be to reset LD_PRELOAD at program start:

int main() {
# ifdef __SANITIZE_ADDRESS__
  // Do not sanitize child processes
  // TODO: strip only libasan.so, keep everything else
  unsetenv("LD_PRELOAD");
# endif

Upvotes: 1

Related Questions