diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-02-07 16:06:33 +0100 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2020-02-07 16:06:33 +0100 |
| commit | be02616c869c5fe089bc9a80ea44817df2f5c2ba (patch) | |
| tree | 7c696c0250ef6ca0bee09cfe83716d1ca53cd69e /lib/std/debug.zig | |
| parent | 786700249e4a3547d4adb73f30b9c42d014b40e3 (diff) | |
| download | zig-be02616c869c5fe089bc9a80ea44817df2f5c2ba.tar.gz zig-be02616c869c5fe089bc9a80ea44817df2f5c2ba.zip | |
debug: Show a nice error message on SIGBUS
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 100ac3e798..b9fafab07c 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -2256,6 +2256,7 @@ pub fn attachSegfaultHandler() void { os.sigaction(os.SIGSEGV, &act, null); os.sigaction(os.SIGILL, &act, null); + os.sigaction(os.SIGBUS, &act, null); } fn resetSegfaultHandler() void { @@ -2273,6 +2274,7 @@ fn resetSegfaultHandler() void { }; os.sigaction(os.SIGSEGV, &act, null); os.sigaction(os.SIGILL, &act, null); + os.sigaction(os.SIGBUS, &act, null); } fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_void) callconv(.C) noreturn { @@ -2285,6 +2287,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_vo switch (sig) { os.SIGSEGV => std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}), os.SIGILL => std.debug.warn("Illegal instruction at address 0x{x}\n", .{addr}), + os.SIGBUS => std.debug.warn("Bus error at address 0x{x}\n", .{addr}), else => unreachable, } switch (builtin.arch) { |
