zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit dae703d3c028eab3bf98d89d2bca1abc75f864fa (tree)
parent 2ab650b4817cbb22244c17de828e82cbb0ccf15e
Author: mlugg <mlugg@mlugg.co.uk>
Date:   Thu, 18 Sep 2025 15:03:45 +0100

std.posix.abort: only trigger breakpoint on Windows if being debugged

Processes should reasonably be able to expect their children to abort
with typical exit codes, rather than a debugger breakpoint signal. This
flag in the PEB is what would be checked by `IsDebuggerPresent` in
kernel32, which is the function you would typically use for this
purpose.

This fixes `test-stack-trace` failures on Windows, as these tests were
expecting exit code 3 to indicate abort.

Diffstat:
Mlib/std/posix.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/std/posix.zig b/lib/std/posix.zig @@ -689,7 +689,7 @@ pub fn abort() noreturn { // even when linking libc on Windows we use our own abort implementation. // See https://github.com/ziglang/zig/issues/2071 for more details. if (native_os == .windows) { - if (builtin.mode == .Debug) { + if (builtin.mode == .Debug and windows.peb().BeingDebugged != 0) { @breakpoint(); } windows.kernel32.ExitProcess(3);