diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-10-31 17:24:22 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-12-16 13:06:02 -0500 |
| commit | f8cd981c04e60530b99c9f360c3e79041d75ca96 (patch) | |
| tree | b5d355aa94f0d64e0cd9b8f237f056b3dce75030 /lib/std | |
| parent | cb5a5ebb200c6e7f87178e26dac453e8c91948d7 (diff) | |
| download | zig-f8cd981c04e60530b99c9f360c3e79041d75ca96.tar.gz zig-f8cd981c04e60530b99c9f360c3e79041d75ca96.zip | |
use -fsanitize=undefined for C code in safe build modes
closes #3569
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/debug.zig | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 69b9e894bb..9b24e1acd3 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -2404,6 +2404,7 @@ pub fn attachSegfaultHandler() void { }; os.sigaction(os.SIGSEGV, &act, null); + os.sigaction(os.SIGILL, &act, null); } fn resetSegfaultHandler() void { @@ -2420,6 +2421,7 @@ fn resetSegfaultHandler() void { .flags = 0, }; os.sigaction(os.SIGSEGV, &act, null); + os.sigaction(os.SIGILL, &act, null); } extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_void) noreturn { @@ -2429,8 +2431,11 @@ extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *con resetSegfaultHandler(); const addr = @ptrToInt(info.fields.sigfault.addr); - std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}); - + 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}), + else => unreachable, + } switch (builtin.arch) { .i386 => { const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); |
