Virtual terminal wrongly parsed input buffer under load #4284

Closed
opened 2026-01-30 23:42:56 +00:00 by claunia · 2 comments
Owner

Originally created by @skyline75489 on GitHub (Oct 5, 2019).

Environment

Windows build number: Version 10.0.18362.356
Windows Terminal version (if applicable): dev build on 0691c21876229dc573a18473ca04bfc78c0d6803

Any other software?

Steps to reproduce

Open several cmatrix tabs and see what it looks like. Some color attribute are displayed as 32m. Now open a new tab and quickly type things, the buffer are likely to be messed up.

Expected behavior

Rendering is correct.

Actual behavior

Not really.

Analysis

As a follow-up of #1311, in which other people also noticed this problem. It seems like one tab is affecting another when under heavy load. I've explored the code a little bit and found that it was not the case.

When under heavy load, contty is lagged and compressed several sequential key event as one. For example, if I quickly typed aaaaaaslkd, the received buffer in StateMachine::ProcessString (link) looks like this:

"\x1b[93m\x1b[15;22Haaaaaa\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaas\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaasl\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaaslk\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaaslkd\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaas...

If we break it up, it wiil be:

\x1b[93m\x1b[15;22Haaaaaa\x1b[?25h\x1b[m\x1b[?25l
\x1b[93m\x1b[15;22Haaaaaas\x1b[?25h\x1b[m\x1b[?25l
\x1b[93m\x1b[15;22Haaaaaasl\x1b[?25h\x1b[m\x1b[?25l
\x1b[93m\x1b[15;22Haaaaaaslk\x1b[?25h\x1b[m\x1b[?25l
\x1b[93m\x1b[15;22Haaaaaaslkd\x1b[?25h\x1b[m\x1b[?25l
\x1b[93m\x1b[15;22Haaaaaas...

This seems reasonable. But StateMachine::ProcessString seems to be wrongly handling this and print control string like \x1b[?25h into the screen buffer.

I've look to hear you guys opinion on this one, especially @zadjii-msft who left a comment in #1311.

Originally created by @skyline75489 on GitHub (Oct 5, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Version 10.0.18362.356 Windows Terminal version (if applicable): dev build on 0691c21876229dc573a18473ca04bfc78c0d6803 Any other software? ``` # Steps to reproduce Open several `cmatrix` tabs and see what it looks like. Some color attribute are displayed as `32m`. Now open a new tab and quickly type things, the buffer are likely to be messed up. <!-- A description of how to trigger this bug. --> # Expected behavior Rendering is correct. # Actual behavior Not really. <!-- What's actually happening? --> # Analysis As a follow-up of #1311, in which other people also noticed this problem. It seems like one tab is affecting another when under heavy load. I've explored the code a little bit and found that it was not the case. When under heavy load, contty is lagged and compressed several sequential key event as one. For example, if I quickly typed `aaaaaaslkd`, the received buffer in `StateMachine::ProcessString` ([link](https://github.com/microsoft/terminal/blob/master/src/terminal/parser/stateMachine.cpp#L1343)) looks like this: ```plaintext "\x1b[93m\x1b[15;22Haaaaaa\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaas\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaasl\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaaslk\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaaslkd\x1b[?25h\x1b[m\x1b[?25l\x1b[93m\x1b[15;22Haaaaaas... ``` If we break it up, it wiil be: ```plaintext \x1b[93m\x1b[15;22Haaaaaa\x1b[?25h\x1b[m\x1b[?25l \x1b[93m\x1b[15;22Haaaaaas\x1b[?25h\x1b[m\x1b[?25l \x1b[93m\x1b[15;22Haaaaaasl\x1b[?25h\x1b[m\x1b[?25l \x1b[93m\x1b[15;22Haaaaaaslk\x1b[?25h\x1b[m\x1b[?25l \x1b[93m\x1b[15;22Haaaaaaslkd\x1b[?25h\x1b[m\x1b[?25l \x1b[93m\x1b[15;22Haaaaaas... ``` This seems reasonable. But `StateMachine::ProcessString` seems to be wrongly handling this and print control string like `\x1b[?25h` into the screen buffer. I've look to hear you guys opinion on this one, especially @zadjii-msft who left a comment in #1311.
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-30 23:42:56 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Oct 8, 2019):

So, there's a chance that this could be related to #3108 (fixed in #3110) -- the VT parsers were accidentally sharing global state, and that sharing would result in one VT parser "completing" parsing on another's behalf leaving the remaining one to just pop its remaining sequences out as text.

I've tried four tabs with cmatrix running as a test with #3110 in, and I can't reproduce this issue any longer.

@DHowett-MSFT commented on GitHub (Oct 8, 2019): So, there's a chance that this could be related to #3108 (fixed in #3110) -- the VT parsers were accidentally sharing global state, and that sharing would result in one VT parser "completing" parsing on another's behalf leaving the remaining one to just pop its remaining sequences out as text. I've tried four tabs with cmatrix running as a test with #3110 in, and I can't reproduce this issue any longer.
Author
Owner

@skyline75489 commented on GitHub (Oct 8, 2019):

@DHowett-MSFT That's probably it. I've tried cmatrix with #3110 and I can't reproduce this, either. Turns out it is tabs affecting each other, just in a very unusual and subtle way.

@skyline75489 commented on GitHub (Oct 8, 2019): @DHowett-MSFT That's probably it. I've tried cmatrix with #3110 and I can't reproduce this, either. Turns out it is tabs affecting each other, just in a very unusual and subtle way.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4284