zig

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

commit be02616c869c5fe089bc9a80ea44817df2f5c2ba (tree)
parent 786700249e4a3547d4adb73f30b9c42d014b40e3
Author: LemonBoy <thatlemon@gmail.com>
Date:   Fri,  7 Feb 2020 16:06:33 +0100

debug: Show a nice error message on SIGBUS

Diffstat:
Mlib/std/debug.zig | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git 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) {