Skip to content

terminal: fix stale cursor style/hyperlink state after scroll clear - #13997

Merged
mitchellh merged 1 commit into
mainfrom
ref-bugs
Aug 24, 2026
Merged

mitchellh merged 1 commit into
mainfrom
ref-bugs

Conversation

@mitchellh

Copy link
Copy Markdown
Contributor

Clearing the screen into scrollback and then printing could crash debug builds with a page integrity violation, or silently corrupt style/hyperlink reference counts in release builds. Found in #13991 via fuzzing.

The cursor's style and hyperlink IDs are only valid on the page the cursor is on. When the scroll clear moved the start of the fresh screen onto a new page, the reset path in cursorReload updated the cursor's position directly instead of going through cursorChangePin, so the cursor kept IDs from its old page. On the new page those IDs pointed at entries that were dead or belonged to something else, and the next print used them.

Fix this by making the reset path go through cursorChangePin like every other cross-page cursor move, which releases the style and hyperlink from the old page and recreates them on the new one.

Clearing the screen into scrollback and then printing could crash debug 
builds with a page integrity violation, or silently corrupt style/hyperlink
reference counts in release builds. Found in #13991 via fuzzing.

The cursor's style and hyperlink IDs are only valid on the page the
cursor is on. When the scroll clear moved the start of the fresh
screen onto a new page, the reset path in cursorReload updated the
cursor's position directly instead of going through cursorChangePin,
so the cursor kept IDs from its old page. On the new page those IDs
pointed at entries that were dead or belonged to something else, and
the next print used them.

Fix this by making the reset path go through `cursorChangePin` like
every other cross-page cursor move, which releases the style and
hyperlink from the old page and recreates them on the new one.
@mitchellh mitchellh added this to the 1.4.0 milestone Aug 24, 2026
@mitchellh
mitchellh requested a review from a team as a code owner August 24, 2026 19:05
@ghostty-bot ghostty-bot Bot added the vt Control sequence related label Aug 24, 2026
@mitchellh
mitchellh merged commit 7c49e72 into main Aug 24, 2026
115 checks passed
@mitchellh
mitchellh deleted the ref-bugs branch August 24, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vt Control sequence related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant