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