fix(shutdown): use exit() under AddressSanitizer

system_exit() (= _exit()) on Linux skips C++ destructors and atexit
hooks, including ASan's leak-and-error report. Under sanitizer builds
we want that report. Switch to plain exit() when __SANITIZE_ADDRESS__
is defined; native posix shutdown still uses _exit().
This commit is contained in:
Julian Oes
2026-04-25 19:53:46 +12:00
committed by Ramon Roche
parent 9b62a1701d
commit 22a6264ed4

View File

@@ -283,7 +283,11 @@ static void shutdown_worker(void *arg)
#elif defined(__PX4_POSIX)
// simply exit on posix if real shutdown (poweroff) not available
PX4_INFO_RAW("Exiting NOW.");
#if defined(__SANITIZE_ADDRESS__) || defined(__has_feature) && __has_feature(address_sanitizer)
exit(0); // Use exit() instead of _exit() so ASAN can report errors
#else
system_exit(0);
#endif
#else
PX4_PANIC("board shutdown not available");
#endif