From dea32d2a359d852b17e48aa55c0a41eca641e21f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 09:22:10 -0300 Subject: test: Session.initShared's startup config lives in the session's arena, not the constructor's frame: the core keeps the slice and a Restore applies it again, which read freed memory (an `init file line 1: unknown word` of 0xAA bytes in the log after every Restore in the suite) Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/session.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/session.zig b/test/session.zig index 136d34d1..fd956aa9 100644 --- a/test/session.zig +++ b/test/session.zig @@ -90,9 +90,13 @@ pub const Session = struct { /// A session showing a scratch pane, keeping its state in the state /// file in `dir` (its DumpDir), as every session of a user shares one. pub fn initShared(gpa: std.mem.Allocator, dir: []const u8) !Session { - var config: [4200]u8 = undefined; - const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24, .state = .disk, .startup_config = try std.fmt.bufPrint(&config, "DumpDir {s}\n", .{dir}) }); - var s: Session = .{ .core = p, .arena = .init(gpa) }; + // The core keeps the config's slice (a Restore applies it again): + // the session's arena owns it, not this frame. + var arena: std.heap.ArenaAllocator = .init(gpa); + errdefer arena.deinit(); + const config = try std.fmt.allocPrint(arena.allocator(), "DumpDir {s}\n", .{dir}); + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24, .state = .disk, .startup_config = config }); + var s: Session = .{ .core = p, .arena = arena }; s.drain(); return s; } -- cgit v1.3