From aa3ff349f840f568ea0f052c1f051cdc0dbb18c1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 09:16:28 -0300 Subject: Kind, dump, replica: a plain kind's state opened or closed in a pane that stays (a picker's preview of a PDF, Pick.showKind; a file changed under its pane; an addon reloaded) is a write outside a client's rollback copy, so a client lets the copy go with that unit and never replays it over the copy (agent T23's find, which blocked the install: the soak `replicas -- --clients 5 --rtt 30,80,207` died with `allocator leaks detected` at seed 0 rtt 80 on T1's base and on M2, MuPDF's allocations of documents a picker previewed: contexts, documents, lanes, from Kind.reopen under Pick.showKind); THE CAUSE: no path of the preview forgets its close (the next row and a source change close through Pick.preview, Esc and every roll-up through restore and putBack, ⏎ through land's roll-up, a pane's end through teardownPane, the session's through Core.deinit; a dump carries the slot and the client's join opens it, closed the same ways), but replica.confirm's `ahead` rule: a client idle with its copy taken ahead (Replica.ready) replays the session's units on it and keeps each in `since` to replay again when the copy is put back, unless the unit wrote outside the copy (Pardes.outside, counted by the emulators alone) or opened or closed a pane (its serials); a preview opens the pdf addon's state in the pane the picker lands in, which stays, and that state (the document and its lanes, MuPDF's on the kind heap, the addon's `Own` found by its block's address) is no copy's; so a rollback (another's unit before the client's own key) put the copy back, the epoch freed the block, and the replay opened the document again for a new block: the first was never closed (and its `Own`, keyed by an address the epoch hands out again, could be found for another block); THE FIX: Kind.reopen and Kind.close count a plain kind's open and close in Pardes.outside, by the registry's PA_PLAIN, on every side alike whether the kind's code runs there or not (a client without the library counts as the session does), so confirm's one question lets such a unit go with the copy; dump.plainHere, a client's own open of a plain kind's pane at its join and no step of the session's, puts the count back to the session's as dumped; Term.Outside's and Pardes.outside's docs say so; RUN (TEST FIRST): replica.zig "a picker's preview opens and closes a plain kind's state in the pane it lands in, no pane opened or closed: ..." (a plain test kind `Owned` noting each state it opens and letting it go at its close, as the pdf addon's `Own`; files `.own`): a session at notes.txt in a work tree with paper.own, a client joined in its own view running the kind, idle with its copy taken ahead while the session types `SPC f f p` (the preview through the kind in notes.txt's pane), then a key of the client's own on top and the session's own key first (a rollback), the client's key, Esc; asks the digests equal at each end and no state left noted after both cores end: fails on M2 (8959b031dc33) at the last check (expected 0, found 1), passes now; the soak with the pdf addon (`zig build replicas -Dplatform=tui -- --clients 5 --rtt 30,80,207`, every addon the build has): diverged 0, unequal 0, quiet checks 508/0 474/0 665/0, stops not on may_wait 0, the corpus 22 of 22 scenes the same, no leak, the pdf panes the session opened 8, 6 and 5; a user could hit it as a client of a session whose picker previewed a PDF (a far client in a pair, a window joined to a terminal's session): a document leaked in the client at each rollback over such a preview, and pages drawn from another document's state where an address came back; NEW HOT PATHS: none per key or frame (a plain kind's open and close count one integer; a client lets its copy go at such a unit, as at a pane's open); GATES: core-test 1163/1337 (174 skipped: +1), its globals test (`nothing of a core is a process global`: the test kind's var in its test); no dump layout change (Pardes.outside was dumped and digested already; its values move at a plain kind's open and close, on every side alike); load 1.0 to 8.4 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Core.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'core/Core.zig') diff --git a/core/Core.zig b/core/Core.zig index 3a2e1f51..b80fec2b 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -304,9 +304,10 @@ n_look_src: usize = 0, look_walk_owner: ?u32 = null, /// hands out Pane.serial; monotonic, never reused next_serial: u32 = 0, -/// The writes of its terminals' emulators, which no rollback copy holds -/// (Term.Outside): digested, dumped and copied as any field, so the same on -/// every side; the replica engine's one question of a unit reads it. +/// The writes of its terminals' emulators, and the opens and closes of its +/// plain kinds' states (Kind.reopen, Kind.close), which no rollback copy +/// holds (Term.Outside): digested, dumped and copied as any field, so the +/// same on every side; the replica engine's one question of a unit reads it. outside: pardes.Term.Outside = .{}, /// The column whose tag the running command came from, while it runs: /// the column acme's commands take from their Text's col. -- cgit v1.3