aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-22 15:13:48 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:12 -0800
commit78c4fcfcd89e80ef70cf4cbb13f5100c84432496 (patch)
tree42485088a2d1555c154d28f5013f89f4e6297cd0
parent3c2f5adf41f0e75fd5e8f6661891dd7d4fa770a9 (diff)
downloadzig-78c4fcfcd89e80ef70cf4cbb13f5100c84432496.tar.gz
zig-78c4fcfcd89e80ef70cf4cbb13f5100c84432496.zip
std.debug.lockStderr: cancel protection rather than recancel
because we need to return the value
-rw-r--r--lib/std/debug.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 25a0bc120d..88af16666f 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -281,8 +281,10 @@ pub const sys_can_stack_trace = switch (builtin.cpu.arch) {
/// application's chosen `Io` implementation.
pub fn lockStderr(buffer: []u8) Io.LockedStderr {
const io = std.options.debug_io;
+ const prev = io.swapCancelProtection(.blocked);
+ defer _ = io.swapCancelProtection(prev);
return io.lockStderr(buffer, null) catch |err| switch (err) {
- error.Canceled => io.recancel(),
+ error.Canceled => unreachable, // Cancel protection enabled above.
};
}