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 {...@@ -2256,6 +2256,7 @@ pub fn attachSegfaultHandler() void {
22562256
2257 os.sigaction(os.SIGSEGV, &act, null);2257 os.sigaction(os.SIGSEGV, &act, null);
2258 os.sigaction(os.SIGILL, &act, null);2258 os.sigaction(os.SIGILL, &act, null);
2259 os.sigaction(os.SIGBUS, &act, null);
2259}2260}
22602261
2261fn resetSegfaultHandler() void {2262fn resetSegfaultHandler() void {
...@@ -2273,6 +2274,7 @@ fn resetSegfaultHandler() void {...@@ -2273,6 +2274,7 @@ fn resetSegfaultHandler() void {
2273 };2274 };
2274 os.sigaction(os.SIGSEGV, &act, null);2275 os.sigaction(os.SIGSEGV, &act, null);
2275 os.sigaction(os.SIGILL, &act, null);2276 os.sigaction(os.SIGILL, &act, null);
2277 os.sigaction(os.SIGBUS, &act, null);
2276}2278}
22772279
2278fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_void) callconv(.C) noreturn {2280fn 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...@@ -2285,6 +2287,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_vo
2285 switch (sig) {2287 switch (sig) {
2286 os.SIGSEGV => std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}),2288 os.SIGSEGV => std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}),
2287 os.SIGILL => std.debug.warn("Illegal instruction at address 0x{x}\n", .{addr}),2289 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}),
2288 else => unreachable,2291 else => unreachable,
2289 }2292 }
2290 switch (builtin.arch) {2293 switch (builtin.arch) {