Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGABRT from std.testing.expect on release-small #5806

Closed
SamTebbs33 opened this issue Jul 6, 2020 · 3 comments
Closed

SIGABRT from std.testing.expect on release-small #5806

SamTebbs33 opened this issue Jul 6, 2020 · 3 comments

Comments

@SamTebbs33
Copy link
Contributor

I am seeing a SIGABRT when using std.testing.expect on a false value and using release-small mode.

test "expect" {
    var value = false;
    @import("std").testing.expect(value);
}

Run with zig test sigabrt.zig --release-small.

The GDB trace is

Starting program: /home/sam/repos/pluto/zig-cache/o/2YK4aFEgzVpWYBVkanixY4E6vNwEB5KoGX4TxL38Tfz7TChRAwVLjx8CZJlQYmM_/test
Test [1/1] test "expect"...test failure
Program received signal SIGABRT, Aborted.
0x0000000000204ebb in std.os.linux.x86_64.syscall4 (number=rt_sigprocmask, arg1=2, arg2=140737488348632, arg3=0,
arg4=8) at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/os/linux/x86_64.zig:42
42 return asm volatile ("syscall"
(gdb) bt
#0 0x0000000000204ebb in std.os.linux.x86_64.syscall4 (number=rt_sigprocmask, arg1=2, arg2=140737488348632, arg3=0,
arg4=8) at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/os/linux/x86_64.zig:42
#1 std.os.linux.sigprocmask (flags=2, set=0x7fffffffe5d8, oldset=0x0)
at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/os/linux.zig:781
#2 std.os.raise (sig=6 '\006') at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/os.zig:242
#3 0x000000000020488b in std.os.abort () at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/os.zig:205
#4 0x0000000000204543 in std.debug.panicExtra (trace=, first_trace_addr=..., args=...)
at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/debug.zig:272
#5 0x0000000000203d1f in std.builtin.default_panic (msg=..., error_return_trace=0x2)
at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/builtin.zig:564
#6 0x000000000020480d in std.testing.expect (ok=false)
at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/testing.zig:193
#7 0x0000000000203ef6 in test "expect" () at /home/sam/repos/pluto/heap.zig:3
#8 0x000000000020dbd7 in std.special.main ()
at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/special/test_runner.zig:47
#9 0x0000000000204880 in std.start.callMain ()
at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/start.zig:252
#10 std.start.initEventLoopAndCallMain () at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/start.zig:225
#11 std.start.callMainWithArgs (argc=1, argv=0x7fffffffe908, envp=...)
at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/start.zig:188
#12 std.start.posixCallMainAndExit () at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/start.zig:179
#13 0x000000000020481c in std.start._start ()
at /home/sam/bin/zig-linux-x86_64-0.6.0+abcd4ea5d/lib/zig/std/start.zig:123

@Vexu
Copy link
Member

Vexu commented Jul 11, 2020

std.testing.expect calls @panic which calls std.os.abort, what do you expect to happen when the test fails?

@SamTebbs33
Copy link
Contributor Author

SamTebbs33 commented Jul 11, 2020

I expected there to be a stacktrace that is seen with debug mode. Unless this is purposefully left out of release mode.

@SamTebbs33
Copy link
Contributor Author

Looking at the docs, I realise that this is intentional. I wasn't aware, sorry for the noise!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants