zig icon indicating copy to clipboard operation
zig copied to clipboard

zig build test hangs when a panic occurs in the test

Open saltzm opened this issue 1 year ago • 0 comments

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

If I write a test like:

test "panic" {
    std.debug.panic("panic\n", .{});
}

and I run zig build test, it just hangs. If I've modified the source since the last run, it hangs looking like this:

$ zig build test
steps [3/5] zig test Debug native... LLVM Emit Object...

If instead I run zig build test to get the zig test invocation, and run zig test directly without the --listen, it at least prints:

Test [1/1] main.test.panic... thread 1865483 panic: panic

But then still hangs. When I attach gdb to the hanging test process this is the stack trace I get:

(gdb) thread apply all bt

Thread 1 (Thread 0xffff84dc0010 (LWP 1865776)):
#0  0x0000ffff84d66d14 in msync (addr=<optimized out>, length=4096, flags=1) at ../sysdeps/unix/sysv/linux/msync.c:25
#1  0x0000000001098624 in posix.msync (memory=..., flags=1) at /snap/zig/11354/lib/std/posix.zig:4698
#2  0x00000000010843d8 in debug.StackIterator.isValidMemory (address=281474931325088) at /snap/zig/11354/lib/std/debug.zig:691
#3  0x00000000010a8594 in dwarf.DwarfInfo.unwindFrame (di=0xffff84dbf1e8, context=0xfffffd4b7238, explicit_fde_offset=...) at /snap/zig/11354/lib/std/dwarf.zig:1702
#4  0x00000000010a729c in debug.StackIterator.next_unwind (self=0xfffffd4b7218) at /snap/zig/11354/lib/std/debug.zig:724
#5  0x0000000001098aac in debug.StackIterator.next_internal (self=0xfffffd4b7218) at /snap/zig/11354/lib/std/debug.zig:734
#6  0x00000000010849e4 in debug.StackIterator.next (self=0xfffffd4b7218) at /snap/zig/11354/lib/std/debug.zig:654
#7  0x000000000108472c in debug.writeCurrentStackTrace__anon_7768 (out_stream=..., debug_info=0x1117c10 <debug.self_debug_info>, tty_config=..., start_addr=...) at /snap/zig/11354/lib/std/debug.zig:795
#8  0x000000000104bf84 in debug.dumpCurrentStackTrace (start_addr=...) at /snap/zig/11354/lib/std/debug.zig:188
#9  0x0000000001042770 in debug.panicImpl (trace=0x0, first_trace_addr=..., msg=...) at /snap/zig/11354/lib/std/debug.zig:482
#10 0x0000000001041ad8 in builtin.default_panic (msg=..., error_return_trace=0x0, ret_addr=...) at /snap/zig/11354/lib/std/builtin.zig:845
#11 0x000000000104226c in debug.panicExtra__anon_1909 (trace=0x0, ret_addr=...) at /snap/zig/11354/lib/std/debug.zig:434
#12 0x0000000001041704 in debug.panic__anon_946 () at /snap/zig/11354/lib/std/debug.zig:409
#13 0x00000000010416dc in main.test.panic () at main.zig:1194
#14 0x000000000104b4e4 in test_runner.mainTerminal () at /snap/zig/11354/lib/compiler/test_runner.zig:158
#15 0x00000000010420b0 in test_runner.main () at /snap/zig/11354/lib/compiler/test_runner.zig:35
#16 0x0000000001041a58 in start.callMain () at /snap/zig/11354/lib/std/start.zig:501
#17 start.callMainWithArgs () at /snap/zig/11354/lib/std/start.zig:469
#18 start.main (c_argc=1, c_argv=0xfffffd4b9a48, c_envp=0xfffffd4b9a58) at /snap/zig/11354/lib/std/start.zig:484

Expected Behavior

I expect zig build test to show that a panic occurred and terminate.

saltzm avatar May 20 '24 20:05 saltzm