From 779255dea5286054d73baaca89cedd46344be309 Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Mon, 03 Aug 2026 19:10:07 +0000 Subject: [PATCH] main: use_gpa retains metadata to catch use-after-free at the use site Co-Authored-By: Claude Fable 5 --- src/main.zig | 4 ++++ 1 file(s) changed, 4 insertion(s)(+), 0 deletion(s)(-) diff --git a/src/main.zig b/src/main.zig --- a/src/main.zig +++ b/src/main.zig @@ -181,6 +181,10 @@ // GPA logs every allocation that was never freed, with stack traces. var gpa: std.heap.DebugAllocator(.{ .stack_trace_frames = if (build_options.use_gpa) 8 else 0, + // catch use-after-free at the use site with the free site's stack: + // freed regions are kept unmapped-but-tracked instead of recycled. + .retain_metadata = build_options.use_gpa, + .never_unmap = build_options.use_gpa, }) = .init; defer if (build_options.use_gpa) { log.info("GPA: checking for leaks...", .{}); -- tangled.sh