[Toybox] Debian's gcc-8 doesn't respect ASAN_OPTIONS=detect_leaks=0

Rob Landley rob at landley.net
Sat Dec 24 06:59:46 PST 2022


I was trying to figure out why "ASAN=1 make test_sh" failed on the very first
test, and I traced it down to the memory leak detector going "you're letting
exit free memory for you!" (yes, I know?) and then wasting another hour digging
through the build plumbing trying to figure out why the
ASAN_OPTIONS=detect_leaks=0 that scripts/portability.sh is exporting in the ASAN
case wasn't making it through to the final call to gcc *.o and...

It is. The problem is that the gcc in devuan beowulf is ignoring it. This
doesn't show up in most of the other toybox cases because xexit() calls _xexit()
which calls _exit(). I.E. we never return through the libc plumbing error path,
we do our own cleanup and call the syscall ourselves. But in sh.c, exit_main()
is calling libc's exit() so in this ONE case if you explicitly "exit" from the
shell, ASAN's leak detector runs.

I've worked around it for now by sticking

  const char *__asan_default_options() { return "detect_leaks=0"; }

into main.c which made it stop doing that, but WOW this is janky infrastructure.

Rob


More information about the Toybox mailing list