aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-12-01 13:12:08 +0100
committerAndrew Kelley <andrew@ziglang.org>2020-12-02 16:34:51 -0800
commitcb63ecd6e9a9c539caf0a04278618f55b9d46bba (patch)
treea639d9646555122990752e993afc6ce4478fef40 /lib/std/debug.zig
parentd4c167f3cd09533995aa66109b86a1a28cd21c18 (diff)
downloadzig-cb63ecd6e9a9c539caf0a04278618f55b9d46bba.tar.gz
zig-cb63ecd6e9a9c539caf0a04278618f55b9d46bba.zip
std: Add nosuspend around stderr.print calls
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 0f1a1e8ae1..9e453ba660 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -1762,13 +1762,15 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v
};
// Don't use std.debug.print() as stderr_mutex may still be locked.
- const stderr = io.getStdErr().writer();
- _ = switch (sig) {
- os.SIGSEGV => stderr.print("Segmentation fault at address 0x{x}\n", .{addr}),
- os.SIGILL => stderr.print("Illegal instruction at address 0x{x}\n", .{addr}),
- os.SIGBUS => stderr.print("Bus error at address 0x{x}\n", .{addr}),
- else => unreachable,
- } catch os.abort();
+ nosuspend {
+ const stderr = io.getStdErr().writer();
+ _ = switch (sig) {
+ os.SIGSEGV => stderr.print("Segmentation fault at address 0x{x}\n", .{addr}),
+ os.SIGILL => stderr.print("Illegal instruction at address 0x{x}\n", .{addr}),
+ os.SIGBUS => stderr.print("Bus error at address 0x{x}\n", .{addr}),
+ else => unreachable,
+ } catch os.abort();
+ }
switch (builtin.arch) {
.i386 => {
@@ -1821,13 +1823,15 @@ fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, comptime msg: u
if (@hasDecl(windows, "CONTEXT")) {
const regs = info.ContextRecord.getRegs();
// Don't use std.debug.print() as stderr_mutex may still be locked.
- const stderr = io.getStdErr().writer();
- _ = switch (msg) {
- 0 => stderr.print("{s}\n", .{format.?}),
- 1 => stderr.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}),
- 2 => stderr.print("Illegal instruction at address 0x{x}\n", .{regs.ip}),
- else => unreachable,
- } catch os.abort();
+ nosuspend {
+ const stderr = io.getStdErr().writer();
+ _ = switch (msg) {
+ 0 => stderr.print("{s}\n", .{format.?}),
+ 1 => stderr.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}),
+ 2 => stderr.print("Illegal instruction at address 0x{x}\n", .{regs.ip}),
+ else => unreachable,
+ } catch os.abort();
+ }
dumpStackTraceFromBase(regs.bp, regs.ip);
os.abort();