Certain sequences with default parameters can trigger a crash #19767

Closed
opened 2026-01-31 06:53:05 +00:00 by claunia · 0 comments
Owner

Originally created by @j4james on GitHub (Apr 25, 2023).

Windows Terminal version

1.17.1023

Windows build number

10.0.19045.2728

Other Software

No response

Steps to reproduce

  1. Open a bash shell.
  2. Execute printf "\e[\$r"

Expected Behavior

That sequence executes the DECCARA control with all default parameters. That should have the effect of resetting the attributes of everything on the screen.

Actual Behavior

The terminal hangs for a second, and then the tab closes (assumedly because the underlying conhost has crashed).

The problem arises when using the VTParameters::subspan method to access an offset beyond the end of the original span. Other than the DECCARA sequence, this can also be triggered by DECRARA and DECPS. In the latter case, the whole terminal can crash rather than just the active tab. That may just be a matter of chance though.

My suggested fix would be to change the VTParameters::subspan implementation here:

5ed3c76dcb/src/terminal/adapter/DispatchTypes.hpp (L187)

to something like this:

    const auto subValues = _values.subspan(std::min(offset, _values.size()));

That way an offset beyond the end of the source span would just produce an empty span (that's what I mistakenly assumed the subspan was already doing).

Originally created by @j4james on GitHub (Apr 25, 2023). ### Windows Terminal version 1.17.1023 ### Windows build number 10.0.19045.2728 ### Other Software _No response_ ### Steps to reproduce 1. Open a bash shell. 2. Execute `printf "\e[\$r"` ### Expected Behavior That sequence executes the `DECCARA` control with all default parameters. That should have the effect of resetting the attributes of everything on the screen. ### Actual Behavior The terminal hangs for a second, and then the tab closes (assumedly because the underlying conhost has crashed). The problem arises when using the `VTParameters::subspan` method to access an offset beyond the end of the original span. Other than the `DECCARA` sequence, this can also be triggered by `DECRARA` and `DECPS`. In the latter case, the whole terminal can crash rather than just the active tab. That may just be a matter of chance though. My suggested fix would be to change the `VTParameters::subspan` implementation here: https://github.com/microsoft/terminal/blob/5ed3c76dcbf2d1ad7dc57c599c85c85713b0294f/src/terminal/adapter/DispatchTypes.hpp#L187 to something like this: ````cpp const auto subValues = _values.subspan(std::min(offset, _values.size())); ```` That way an offset beyond the end of the source span would just produce an empty span (that's what I mistakenly assumed the `subspan` was already doing).
claunia added the Needs-TriageIssue-BugIn-PR labels 2026-01-31 06:53:05 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19767