Skip to content

fix: six v0.11.12 runtime issues (record, frames, XTGETTCAP, Drop) - #886

Merged
vyncint merged 7 commits into
mainfrom
fix/01112-rt
Dec 2, 2026
Merged

vyncint merged 7 commits into
mainfrom
fix/01112-rt

Conversation

@vyncint

@vyncint vyncint commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Six runtime issues from the v0.11.12 milestone, one commit each, each with tests that fail without the fix.

Local: cargo test --workspace --all-features passed 1003 tests, with 0 failed. frames.rs passed 12 runs at 1, 9 and 17 threads. Stress is dispatched on this branch, since #836 changes wait semantics.

Closes #850
Closes #837
Closes #831
Closes #836
Closes #855
Closes #835

The asciicast header filled three fields from constants or from the
clock at export: env.TERM was always xterm-256color, a recording with no
frame claimed 80x24, and timestamp was the export time.

- env.TERM is the TERM the child was given, the value XTGETTCAP's TN
  already reports, so the header no longer gives a third answer.
- A recording with no frame takes the terminal's size at record().
- timestamp is the second record() was called in. The asciicast v2 spec
  defines it as the "Unix timestamp of the beginning of the recording
  session"; #309 chose the export time, which is later by the
  recording's length, and made two exports of one recording differ
  (#555). The export-time test now pins the start instead, and the
  file-equals-string comparison is exact again.

Closes #850

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
An application stalled inside a synchronized update, on a read or on a
query's reply, did emit one. wait_frame's timeout said it never had, or
that it had not repainted in response to the input, and pointed at
wait_until; Recorder::stop said "never emitted" too. wait_idle on the
same terminal named the open update, so the diagnosis depended on which
wait timed out.

Both now check for an open update first and say the application began
one and has not ended it. "Never emitted" stays for a terminal that has
seen no Begin. A timeout whose frames were rejected by the predicate
says the next one is open, too.

Closes #837

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
XTGETTCAP answered each key capability with its normal-mode bytes,
whatever mode the application had set, so one that set DECCKM, as
ncurses does through smkx for keypad(), learned \e[A for Up and then
received \eOA from send. xterm answers "the string that xterm would
send" by running the keysym through its own key input, which picks SS3
under DECCKM. The answers now come from Key::encode_modal with the mode
as of the query.

The keys were known only by their terminfo names, while Co and TN were
answered by their termcap names. The termcap names Vim asks by (kb, ku,
kd, kr, kl, kh, @7, kD, kP, kN) are answered now too.

Closes #831

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
resize moved the frame cursor to the count of completed frames, and an
update open at that moment was not counted yet. When the application
ended it after the resize, its frame, drawn at the old size, was the
first one wait_frame offered, so a predicate the old layout satisfied
passed on it: the stale-frame trap the cursor was moved to close. An
application with a spinner or a clock is often painting when the resize
lands, and finishes that frame before it handles SIGWINCH.

resize now notes an update open at the resize. The reader marks the
frame that ends it, and wait_frame steps past that frame while no frame
has been returned since the resize. The sketch's cursor + 1 would have
skipped a real frame when the update never ends: a hard reset closes it
without one, so the reader drops the note then and the next frame is
offered. A timeout while that update is still open names it as begun
before the resize, so the "since the resize" wording stays true.

Closes #836

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
Every recorded frame is a whole Screen, and every Screen holds an Arc of
the graphics log as it stood, with each image's data. RecordingState
charged a frame for its cells only, so a running recorder kept every
image the application sent while the terminal kept capture_graphics of
them: 400 repaints of a 1 MiB image held 400 MiB against a 4 MiB bound.

The recording now counts the image data its frames hold, each payload
once by the address of its shared data, and drops its oldest frames,
reported in dropped(), while that passes capture_graphics, as it does
for cells past record_budget. The newest frame is always kept; its
images are within the bound already, since the terminal's log is.

The test records twenty 1 KiB images against a 4 KiB budget rather than
the issue's 200 MiB, so the test of the bound stays bounded itself.

Closes #855

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
Drop stopped the process group the child leads. A shell with job
control, every interactive one and sh after set -m, starts each job in
a process group of its own in the child's session, and the kernel's
hang-up as the session leader exits reaches the foreground group only,
so a job that ignored SIGHUP ran on after the drop, on a PTY nobody
held. #714's group kill never reached it.

On Linux the session's other groups are read from /proc/<pid>/stat
before the hang-up and again before the kill, and are hung up and
killed with the child's. The session's id is the child's pid, which no
process can take while the child is unreaped or a member lives. A scan
costs about 2 ms with 500 processes, so the second is skipped when the
first found no other group.

macOS would list the session through sysctl with KERN_PROC_SESSION.
That is not done: it could not be run and checked here, so LIMITATIONS
says that off Linux such a job outlives the drop, and the two new tests
are ignored there.

Closes #835

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
@vyncint
vyncint merged commit 341c4d3 into main Dec 2, 2026
17 checks passed
@vyncint
vyncint deleted the fix/01112-rt branch December 2, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment