aboutsummaryrefslogtreecommitdiff
path: root/lib/std/testing.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-02-05 16:39:14 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-02-06 14:23:23 -0800
commitf82ec3f02af68ca25870f8ae3861a416225af554 (patch)
treeb6242f1437470a2a263f1ed2311283c15ce74fb9 /lib/std/testing.zig
parent8282565ce524c14e62e8c30e1feb8afc5c2ab961 (diff)
downloadzig-f82ec3f02af68ca25870f8ae3861a416225af554.tar.gz
zig-f82ec3f02af68ca25870f8ae3861a416225af554.zip
std.testing.allocator: different canary + enable resize traces
Accept a slight performance degradation when unit testing for better debuggability when a leak or double-free is detected.
Diffstat (limited to 'lib/std/testing.zig')
-rw-r--r--lib/std/testing.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig
index 9b56a2ad51..616a138cbd 100644
--- a/lib/std/testing.zig
+++ b/lib/std/testing.zig
@@ -18,6 +18,11 @@ var base_allocator_instance = std.heap.FixedBufferAllocator.init("");
pub const allocator = allocator_instance.allocator();
pub var allocator_instance: std.heap.GeneralPurposeAllocator(.{
.stack_trace_frames = 10,
+ .resize_stack_traces = true,
+ // A unique value so that when a default-constructed
+ // GeneralPurposeAllocator is incorrectly passed to testing allocator, or
+ // vice versa, panic occurs.
+ .canary = @truncate(0x2731e675c3a701ba),
}) = b: {
if (!builtin.is_test) @compileError("testing allocator used when not testing");
break :b .init;