summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 09:22:10 -0300
committerGabriel Schneider <[email protected]>2026-11-10 09:29:11 -0300
commitdea32d2a359d852b17e48aa55c0a41eca641e21f (patch)
tree978ebaa1202bc5f4430c38e394b9bcc81b19cc8d /test
parente617ee11b6fafd48278ef0e371fa1981f8559413 (diff)
downloadpardes-dea32d2a359d852b17e48aa55c0a41eca641e21f.tar.gz
pardes-dea32d2a359d852b17e48aa55c0a41eca641e21f.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
-rw-r--r--test/session.zig10
1 files 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;
}