aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-08 21:00:04 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:08 -0800
commitbee8005fe6817ade9191de0493888b14cdbcac31 (patch)
tree6001bd45ab1118e92a77fe6ebfbf6b332d371a2b /lib/std/debug.zig
parent4a53e5b0b4131c6b8e18bb551e8215e425f8ac71 (diff)
downloadzig-bee8005fe6817ade9191de0493888b14cdbcac31.tar.gz
zig-bee8005fe6817ade9191de0493888b14cdbcac31.zip
std.heap.DebugAllocator: never detect TTY config
instead, allow the user to set it as a field. this fixes a bug where leak printing and error printing would run tty config detection for stderr, and then emit a log, which is not necessary going to print to stderr. however, the nice defaults are gone; the user must explicitly assign the tty_config field during initialization or else the logging will not have color. related: https://github.com/ziglang/zig/issues/24510
Diffstat (limited to 'lib/std/debug.zig')
-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 cb79bb7855..8f1cd50e8e 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -286,11 +286,13 @@ pub fn unlockStdErr() void {
pub fn lockStderrWriter(buffer: []u8) struct { *Writer, tty.Config } {
const global = struct {
var conf: ?tty.Config = null;
+ var single_threaded_io: Io.Threaded = .init_single_threaded;
};
+ const io = global.single_threaded_io.io();
const w = std.Progress.lockStderrWriter(buffer);
// The stderr lock also locks access to `global.conf`.
if (global.conf == null) {
- global.conf = .detect(.stderr());
+ global.conf = .detect(io, .stderr());
}
return .{ w, global.conf.? };
}