authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-01 13:12:08+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-02 17:54:34-07:00
log0ac43154ebf0979672dde2211ee56663a6b0b338
treec080cff9c5f0b20fbba7b5538933068cf7de6342
parent401d091fb4c96fd1b63228476d8060705888c386

std: Add nosuspend around stderr.print calls


1 files changed, 18 insertions(+), 14 deletions(-)

lib/std/debug.zig+18-14
......@@ -1764,13 +1764,15 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v
17641764 };
17651765
17661766 // Don't use std.debug.print() as stderr_mutex may still be locked.
1767 const stderr = io.getStdErr().writer();
1768 _ = switch (sig) {
1769 os.SIGSEGV => stderr.print("Segmentation fault at address 0x{x}\n", .{addr}),
1770 os.SIGILL => stderr.print("Illegal instruction at address 0x{x}\n", .{addr}),
1771 os.SIGBUS => stderr.print("Bus error at address 0x{x}\n", .{addr}),
1772 else => unreachable,
1773 } catch os.abort();
1767 nosuspend {
1768 const stderr = io.getStdErr().writer();
1769 _ = switch (sig) {
1770 os.SIGSEGV => stderr.print("Segmentation fault at address 0x{x}\n", .{addr}),
1771 os.SIGILL => stderr.print("Illegal instruction at address 0x{x}\n", .{addr}),
1772 os.SIGBUS => stderr.print("Bus error at address 0x{x}\n", .{addr}),
1773 else => unreachable,
1774 } catch os.abort();
1775 }
17741776
17751777 switch (builtin.arch) {
17761778 .i386 => {
......@@ -1823,13 +1825,15 @@ fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, comptime msg: u
18231825 if (@hasDecl(windows, "CONTEXT")) {
18241826 const regs = info.ContextRecord.getRegs();
18251827 // Don't use std.debug.print() as stderr_mutex may still be locked.
1826 const stderr = io.getStdErr().writer();
1827 _ = switch (msg) {
1828 0 => stderr.print("{s}\n", .{format.?}),
1829 1 => stderr.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}),
1830 2 => stderr.print("Illegal instruction at address 0x{x}\n", .{regs.ip}),
1831 else => unreachable,
1832 } catch os.abort();
1828 nosuspend {
1829 const stderr = io.getStdErr().writer();
1830 _ = switch (msg) {
1831 0 => stderr.print("{s}\n", .{format.?}),
1832 1 => stderr.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}),
1833 2 => stderr.print("Illegal instruction at address 0x{x}\n", .{regs.ip}),
1834 else => unreachable,
1835 } catch os.abort();
1836 }
18331837
18341838 dumpStackTraceFromBase(regs.bp, regs.ip);
18351839 os.abort();