From e567aadc19f58b1e36098388483294321f3502dd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 18 Nov 2026 23:12:37 -0300 Subject: core: the rollback's two faults read by the probe (pardes-probes P4 b), each shown by a test that fails on the base, and fixed: (a) a terminal's kitty-image cache (TerminalImages.converted, RGBA made of an RGB or grey image) was made with the drawing core's allocator, so on a far client, whose emulator is outside its rollback epoch, a frame drawn under a speculation left the emulator holding epoch-born memory that the rollback freed (reachable since a closed terminal brought back loads the session's dump of it, its images with it): the next frame read the freed map (SIGSEGV in TerminalImages.draw on the base), so the caches are now the emulator's own allocator's and a terminal's close takes none; (b) a far client's slot of a kind whose state is not plain was on the C heap (initDump's image_allocator), so its own Del of such a pane freed the slot outside the epoch, and the rollback by another client's unit put back a pane pointing at it (a general protection fault in Jump.trackJump on the base), so a far client's image_allocator is now its epoch, as every other of its allocators: the free is put off and the Del stays instant; two tests at the end of core/replica.zig; tui core-test 824/966 (142 skipped), shell-test 1001/1004, pane-test 183/184, behaviour-test 274/274 and --replay 274/274, process-test 2 of 144 failed (lspcomplete, lspcompletemoved; winch failed once under load and passed alone), replicas --clients 5 diverged 0 unequal 0 deltas wrong 0 quiet differ 0 at 30/80/207 ms, gui unit-test 1598/1602 with its perf check passing, daemon.py plain, --far and --games pass (--games once timed out at its teardown and passed again; --window-clients failed on the gate's own TMPDIR, a socket path past 108 bytes, and passed on the next change) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/term/terminal.zig | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'core/term/terminal.zig') diff --git a/core/term/terminal.zig b/core/term/terminal.zig index d328748e..d99cfb79 100644 --- a/core/term/terminal.zig +++ b/core/term/terminal.zig @@ -721,12 +721,11 @@ pub fn scrollbackLen(state: ?*State) usize { return @intCast(counting.fullCount()); } -/// Its emulator and what it holds, freed; its kitty images' caches were -/// `gpa`'s. -pub fn close(state: *State, gpa: std.mem.Allocator) void { - if (comptime images_enabled) state.images.deinit(gpa); - state.stream.deinit(); +/// Its emulator and what it holds, freed. +pub fn close(state: *State) void { const own = state.gpa; + if (comptime images_enabled) state.images.deinit(own); + state.stream.deinit(); state.vt.deinit(own); own.destroy(state); } @@ -1502,7 +1501,7 @@ pub fn images(state: *State, gpa: std.mem.Allocator, at: ImagesAt, out: *std.Arr // Nothing to draw, no placeholder to blank and nothing cached to let // go: the common case costs the rows' flags. if (!any_placeholder and screen.kitty_images.placements.count() == 0 and state.images.converted.count() == 0) return; - state.images.draw(gpa, &state.vt, at, rows_of[0..vp_rows], out, frame, frame_cols); + state.images.draw(state.gpa, gpa, &state.vt, at, rows_of[0..vp_rows], out, frame, frame_cols); } test "the luminance table answers exactly what ghostty computes" { -- cgit v1.3