authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-07 16:06:33+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-07 16:06:33+01:00
logbe02616c869c5fe089bc9a80ea44817df2f5c2ba
tree7c696c0250ef6ca0bee09cfe83716d1ca53cd69e
parent786700249e4a3547d4adb73f30b9c42d014b40e3

debug: Show a nice error message on SIGBUS


1 files changed, 3 insertions(+), 0 deletions(-)

lib/std/debug.zig+3
......@@ -2256,6 +2256,7 @@ pub fn attachSegfaultHandler() void {
22562256
22572257 os.sigaction(os.SIGSEGV, &act, null);
22582258 os.sigaction(os.SIGILL, &act, null);
2259 os.sigaction(os.SIGBUS, &act, null);
22592260}
22602261
22612262fn resetSegfaultHandler() void {
......@@ -2273,6 +2274,7 @@ fn resetSegfaultHandler() void {
22732274 };
22742275 os.sigaction(os.SIGSEGV, &act, null);
22752276 os.sigaction(os.SIGILL, &act, null);
2277 os.sigaction(os.SIGBUS, &act, null);
22762278}
22772279
22782280fn 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
22852287 switch (sig) {
22862288 os.SIGSEGV => std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}),
22872289 os.SIGILL => std.debug.warn("Illegal instruction at address 0x{x}\n", .{addr}),
2290 os.SIGBUS => std.debug.warn("Bus error at address 0x{x}\n", .{addr}),
22882291 else => unreachable,
22892292 }
22902293 switch (builtin.arch) {