Address sanitizer does not detect obvious leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi list,

I'm having a weird issue with the address sanitizer on gcc 10.2.0
(Ubuntu 10.2.0-13ubuntu1), Ubuntu x86_64. I'm running a test bench of
code, where the test master forks and executes the individual testcase
in the child process. If the child terminates with error (e.g.,
assertion failed, SIGSEGV or address sanitizer issue), the parent
records this as a failure.

This setup is integrated using CI. When I pushed some code that actually
had an OBVIOUS memory leak, the CI system detected the issue correctly,
but locally I cannot reproduce it at all.

Unless I compile my code using -O0, it never finds the memory leak. At
-O1 it just seems like the memory is not leaking, even though malloc()
is called and returns a valid pointer (which is also used, i.e., the
memory *is* allocated).

As soon as I move the testcase into the parent process (i.e., *same*
code!), the address sanitizer correctly detects and reports the issue.

I'm compiling my code with

-std=c11 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE
-Wall -Werror -Wmissing-prototypes -Wstrict-prototypes
-Werror=implicit-function-declaration -Wno-stringop-truncation -O3 -g3
-pie -fPIE -fsanitize=address -fsanitize=undefined -fsanitize=leak

I could just fix the obvious leak and move on. But I fear I might not
understand why this is happening and have an unreliable CI system that
possibly misses leaks. Therefore I would like to understand what is
going on here.

Any guesses?
Thanks,
Joe



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux