ConPTY pass-through sequences are being truncated #5775

Closed
opened 2026-01-31 00:21:17 +00:00 by claunia · 2 comments
Owner

Originally created by @j4james on GitHub (Jan 5, 2020).

Originally assigned to: @miniksa on GitHub.

Environment

Windows build number: Version 10.0.18362.418
Windows Terminal version (if applicable): commit d711d731d7

Steps to reproduce

  1. Open a bash shell in Windows Terminal
  2. Execute the sequence: printf "\e[?999h 12345 Hello World"

Expected behavior

999 isn't a supported mode, so that should be ignored and passed through to the conpty client. Then the text 12345 Hello World should be output.

Actual behavior

The unrecognized mode sequence gets truncated, losing the final character. and then the start of the text that is output is also truncated, leaving just ello World.

What's happening is that the missing character leaves the state machine in a state where it's waiting for a final character, so it ends up eating the characters that follow, until it gets to the H in Hello World.

I believe this is a regression caused by PR #3956. I think it's the calculation of the _run variable that is off by 1, but it may be more complicated than that:

d711d731d7/src/terminal/parser/stateMachine.cpp (L1252)

Also note that _run is initialized in more than one place.

Originally created by @j4james on GitHub (Jan 5, 2020). Originally assigned to: @miniksa on GitHub. # Environment Windows build number: Version 10.0.18362.418 Windows Terminal version (if applicable): commit d711d731d7d00259b2e0fe5847928c9f1c1121ed # Steps to reproduce 1. Open a bash shell in Windows Terminal 2. Execute the sequence: `printf "\e[?999h 12345 Hello World"` # Expected behavior 999 isn't a supported mode, so that should be ignored and passed through to the conpty client. Then the text ` 12345 Hello World` should be output. # Actual behavior The unrecognized mode sequence gets truncated, losing the final character. and then the start of the text that is output is also truncated, leaving just `ello World`. What's happening is that the missing character leaves the state machine in a state where it's waiting for a final character, so it ends up eating the characters that follow, until it gets to the `H` in `Hello World`. I believe this is a regression caused by PR #3956. I think it's the calculation of the `_run` variable that is off by 1, but it may be more complicated than that: https://github.com/microsoft/terminal/blob/d711d731d7d00259b2e0fe5847928c9f1c1121ed/src/terminal/parser/stateMachine.cpp#L1252 Also note that `_run` is initialized in more than one place.
Author
Owner

@j4james commented on GitHub (Jan 5, 2020):

On further review, I see the _run variable actually serves a different purpose, so changing that is not the solution. It's just not the right thing to be using for the pass-through.

To be honest I think we'd be better off just dropping this pass-through idea as a general concept. If there are specific sequences that we don't support in conhost, but we know another conpty client can handle, then we should be evaluating those on a case by case basis, and deciding whether they're safe to pass through.

The concept only really makes sense for operations that have no interaction with other parts of the system. For example, passing through a sequence to change the cursor color might be OK, but passing through a sequence that sets the left and right margins is never going to work - it'll just leave the conhost and conpty client completely out of sync.

@j4james commented on GitHub (Jan 5, 2020): On further review, I see the `_run` variable actually serves a different purpose, so changing that is not the solution. It's just not the right thing to be using for the pass-through. To be honest I think we'd be better off just dropping this pass-through idea as a general concept. If there are specific sequences that we don't support in conhost, but we know another conpty client can handle, then we should be evaluating those on a case by case basis, and deciding whether they're safe to pass through. The concept only really makes sense for operations that have no interaction with other parts of the system. For example, passing through a sequence to change the cursor color might be OK, but passing through a sequence that sets the left and right margins is never going to work - it'll just leave the conhost and conpty client completely out of sync.
Author
Owner

@miniksa commented on GitHub (Jan 6, 2020):

@j4james, we should file another issue to further refine the reasoning behind what is and is not passthrough. I've taken this issue to generate a PR to restore the behavior I broke so as to not block the next release. Thank you for the find and apologies for the grief.

@miniksa commented on GitHub (Jan 6, 2020): @j4james, we should file another issue to further refine the reasoning behind what is and is not passthrough. I've taken this issue to generate a PR to restore the behavior I broke so as to not block the next release. Thank you for the find and apologies for the grief.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5775