From ac57e8c3a05cdd8f587b6faf47e7f9d2c4357dee Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 15:38:44 -0300 Subject: views: a view drawn or read outside a step (a replica client's own while another is live) leaves the live view's slot and its panes' shares holding nothing, as unpark and drawOthers leave them withParked parked the live view and copied it back, but left its slot (column tags' texts, a chord's argument, the presentation) and each pane's share (its selections) pointing at what the live fields own. A rollback copy walks every slot (src/rollback.zig): once the live view freed one of them and the heap gave the memory to another, the copy saved that and put its old bytes back over it, which `emptied` exists to prevent (the slot left as H5's hypothesis had it, in a path it did not name: Replica.draw and Replica.within). Test (failing before): a view drawn outside a step leaves the live view's slot holding nothing a rollback could put old bytes back through. Co-Authored-By: Claude Opus 5.5 --- src/views.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/views.zig') diff --git a/src/views.zig b/src/views.zig index b9731089..34644a96 100644 --- a/src/views.zig +++ b/src/views.zig @@ -583,6 +583,10 @@ fn withParked(p: *Pardes, k: u8, ctx: anytype, comptime f: fn (@TypeOf(ctx), *Pa park(p); defer { copy(&fields, p, &p.parked[live].?.view); + // Its slot and its panes' shares, stale while it is live, keep no + // pointer to what they handed back, as `unpark` leaves them: a + // replica's rollback copy walks them (`emptied`). + emptied(p, live); p.view = live; for (p.panes) |s| if (s) |pane| { const pv = &pane.pv[live]; @@ -593,6 +597,8 @@ fn withParked(p: *Pardes, k: u8, ctx: anytype, comptime f: fn (@TypeOf(ctx), *Pa pane.rows = pv.rows; } if (pane.file) |*file| file.scroll = pv.scroll; + pv.body.sels = &.{}; + pv.body.nsel = 0; }; } try f(ctx, p, k); -- cgit v1.3