| author | |
| committer | |
| log | f8cd981c04e60530b99c9f360c3e79041d75ca96 |
| tree | b5d355aa94f0d64e0cd9b8f237f056b3dce75030 |
| parent | cb5a5ebb200c6e7f87178e26dac453e8c91948d7 |
| signature | Commit is signed but in an unrecognized format. |
closes #35692 files changed, 13 insertions(+), 2 deletions(-)
lib/std/debug.zig+7-2| ... | ... | @@ -2404,6 +2404,7 @@ pub fn attachSegfaultHandler() void { |
| 2404 | 2404 | }; |
| 2405 | 2405 | |
| 2406 | 2406 | os.sigaction(os.SIGSEGV, &act, null); |
| 2407 | os.sigaction(os.SIGILL, &act, null); | |
| 2407 | 2408 | } |
| 2408 | 2409 | |
| 2409 | 2410 | fn resetSegfaultHandler() void { |
| ... | ... | @@ -2420,6 +2421,7 @@ fn resetSegfaultHandler() void { |
| 2420 | 2421 | .flags = 0, |
| 2421 | 2422 | }; |
| 2422 | 2423 | os.sigaction(os.SIGSEGV, &act, null); |
| 2424 | os.sigaction(os.SIGILL, &act, null); | |
| 2423 | 2425 | } |
| 2424 | 2426 | |
| 2425 | 2427 | 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 |
| 2429 | 2431 | resetSegfaultHandler(); |
| 2430 | 2432 | |
| 2431 | 2433 | const addr = @ptrToInt(info.fields.sigfault.addr); |
| 2432 | std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}); | |
| 2433 | ||
| 2434 | switch (sig) { | |
| 2435 | os.SIGSEGV => std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}), | |
| 2436 | os.SIGILL => std.debug.warn("Illegal instruction at address 0x{x}\n", .{addr}), | |
| 2437 | else => unreachable, | |
| 2438 | } | |
| 2434 | 2439 | switch (builtin.arch) { |
| 2435 | 2440 | .i386 => { |
| 2436 | 2441 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); |
src/codegen.cpp+6| ... | ... | @@ -8973,6 +8973,9 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa |
| 8973 | 8973 | |
| 8974 | 8974 | switch (g->build_mode) { |
| 8975 | 8975 | case BuildModeDebug: |
| 8976 | args.append("-fsanitize=undefined"); | |
| 8977 | args.append("-fsanitize-trap=undefined"); | |
| 8978 | ||
| 8976 | 8979 | // windows c runtime requires -D_DEBUG if using debug libraries |
| 8977 | 8980 | args.append("-D_DEBUG"); |
| 8978 | 8981 | |
| ... | ... | @@ -8985,6 +8988,9 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa |
| 8985 | 8988 | } |
| 8986 | 8989 | break; |
| 8987 | 8990 | case BuildModeSafeRelease: |
| 8991 | args.append("-fsanitize=undefined"); | |
| 8992 | args.append("-fsanitize-trap=undefined"); | |
| 8993 | ||
| 8988 | 8994 | // See the comment in the BuildModeFastRelease case for why we pass -O2 rather |
| 8989 | 8995 | // than -O3 here. |
| 8990 | 8996 | args.append("-O2"); |