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 16:34:51-08:00
logcb63ecd6e9a9c539caf0a04278618f55b9d46bba
treea639d9646555122990752e993afc6ce4478fef40
parentd4c167f3cd09533995aa66109b86a1a28cd21c18

std: Add nosuspend around stderr.print calls


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

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