From 8c083912002f5cfdf268ed45ec217fbd8bde41d0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 22:09:09 -0300 Subject: TagState, Core: a loaded tag state is held to what it indexes, and a told focus to the pane slots (fixes found by item 4's dump fuzz, on line A2): RUN: the 40,000-seed dump fuzz (core/fuzz.zig "a dump and an image cut...", its counts raised to 40,000 join and 1,779 image seeds and its session put in Help, `SPC t w` then `SPC ? hel`, a temporary edit put back) panicked twice before this: `index out of bounds: index 65163, len 64` at TagState.zig helpLeaf (`p.kinds.words[at - flat.len]`), from Band.helpSteps, draw.joinBand, render of a damaged dump's view, and then `index 524288, len 64` at Core.zig reportFocus (`p.panes[old.id]`); THE CAUSE: a dump gives View.tag_state as it was written, and nothing held its indexes after a load: a Help hit past the tree and the registry's words, its rows' cursor past its hits, the field's caret past its text, describe-key's found leaf with no keys; and View.focus_told (main's, unchanged since e9f3712c) is read back as a pane slot unchecked (the seeds land elsewhere since the tag state joined the dump: wire 36); THE FIX: TagState.loaded, from dump.zig afterLoad (both loads): a tag state that does not hold is at rest, its memory of leaves kept; reportFocus asks a slot past MAX_PANES for no pane; a user could hit them only with a damaged dump (a cut file, a flipped byte), and the session panicked on its first frame or key; NOT FIXED: the third run of the fuzz panicked with `double free` in walk.zig slice (walk.zig:1847, from value:1780, oneField:1988, dump.zig:422 loadKnowing: the join road): a damaged back-reference (l.ref) lets two fields share one allocation, both freed on the error path: the loader's, main's; TEST: TagState.zig "a dump's tag state that indexes past what it names is at rest when loaded, and its frame draws" Co-Authored-By: Claude Opus 5.5 --- core/Core.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/Core.zig') diff --git a/core/Core.zig b/core/Core.zig index 5ce635f2..b4d6293e 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -1029,7 +1029,8 @@ fn reportFocus(p: *Pardes) void { // program hears of it a round trip later (a write there would stop the // speculation: pty_write is `keeps_stopping`'s). if (p.tape.speculating) return; - if (v.focus_told) |old| if (p.panes[old.id]) |pane| { + // A damaged dump's pane past the slots names none. + if (v.focus_told) |old| if (old.id < MAX_PANES) if (p.panes[old.id]) |pane| { if (pane.serial == old.serial and pardes.Term.modes(pane.terminal).focus) p.emitWrite(old.id, "\x1b[O"); }; if (want) |new| if (pardes.Term.modes(p.panes[new.id].?.terminal).focus) p.emitWrite(new.id, "\x1b[I"); -- cgit v1.3