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