Compare commits

...

1 Commits

Author SHA1 Message Date
Claude Bot
aced57032c Fix LeakSanitizer detection by using std.c.exit when ASAN is enabled
When AddressSanitizer is enabled, use std.c.exit instead of quick_exit
to allow LeakSanitizer (LSAN) to run its leak detection at program
termination. quick_exit bypasses exit handlers and destructors that
LSAN relies on for leak detection.

The fix checks both the compile-time bun.asan.enabled flag and
Environment.isDebug, since debug builds enable ASAN via compiler flags
rather than Zig build options, making bun.asan.enabled false even when
ASAN is active.

This change enables proper memory leak detection when running Bun
with ASAN_OPTIONS="detect_leaks=1".

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 20:54:47 +00:00

View File

@@ -121,8 +121,14 @@ pub fn exit(code: u32) noreturn {
std.os.windows.kernel32.ExitProcess(code);
},
else => {
bun.c.quick_exit(@bitCast(code));
std.c.abort(); // quick_exit should be noreturn
// Use std.c.exit when ASAN is enabled to allow LeakSanitizer to run
// Check both compile-time flag and debug builds (which have ASAN via compiler flags)
if (comptime bun.asan.enabled or Environment.isDebug) {
std.c.exit(@bitCast(code));
} else {
bun.c.quick_exit(@bitCast(code));
std.c.abort(); // quick_exit should be noreturn
}
},
}
}