Weird parsing and behavior when an unrecognized OSC's ST is split #4291

Open
opened 2026-01-30 23:43:07 +00:00 by claunia · 0 comments
Owner

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

Environment

Windows build number: Win32NT 10.0.18362.0
Windows Terminal version (if applicable): 0.5.2762.0

Steps to reproduce

echo -ne '\e]10;foo\e'; sleep 1; echo -ne '\\'; sleep 5; echo; sleep 1; echo; sleep 10

Expected behavior

Two linefeeds eventually, nothing more.

OSC 10 sets the default foreground, it's not yet supported by WT. You can replace it with any other number that's not yet supported.

The terminating sequence of OSC should be ST accoding to the standard (BEL is a commonly used but nonstandard choice instead). ST in the C0 set is ESC followed by \.

Now we insert a bit of delay in the middle of ST. Such difference in timing should never make a difference in the final outcome, not even when the sequence is unsupported.

Actual behavior

The following weirdnesses occur:

  • A literal \ gets printed. It shouldn't.

  • That \ gets printed 6 seconds after starting the command line, rather than 1 second after. That is, not immediately when received, but when the next character (whether that's a newline or not) is received.

  • Subsequent newlines don't move the cursor to the beginning of the line as expected, but walk downwards in the second column.

So it seems the parser might be stuck in some weird mode??

The bug does not occur if the delay is eliminated and the unsupported escape sequence is printed in a single step. It is completely ignored then, as expected.

The bug does not occur with supported escape sequences either, such as setting the title with OSC 0. It's immune to injected delays, as expected.

Originally created by @egmontkob 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: Win32NT 10.0.18362.0 Windows Terminal version (if applicable): 0.5.2762.0 ``` # Steps to reproduce echo -ne '\e]10;foo\e'; sleep 1; echo -ne '\\'; sleep 5; echo; sleep 1; echo; sleep 10 # Expected behavior Two linefeeds eventually, nothing more. OSC 10 sets the default foreground, it's not yet supported by WT. You can replace it with any other number that's not yet supported. The terminating sequence of `OSC` should be `ST` accoding to the standard (`BEL` is a commonly used but nonstandard choice instead). `ST` in the `C0` set is `ESC` followed by `\`. Now we insert a bit of delay in the middle of `ST`. Such difference in timing should never make a difference in the final outcome, not even when the sequence is unsupported. # Actual behavior The following weirdnesses occur: - A literal `\` gets printed. It shouldn't. - That `\` gets printed 6 seconds after starting the command line, rather than 1 second after. That is, not immediately when received, but when the next character (whether that's a newline or not) is received. - Subsequent newlines don't move the cursor to the beginning of the line as expected, but walk downwards in the second column. So it seems the parser might be stuck in some weird mode?? The bug does not occur if the delay is eliminated and the unsupported escape sequence is printed in a single step. It is completely ignored then, as expected. The bug does not occur with supported escape sequences either, such as setting the title with OSC 0. It's immune to injected delays, as expected.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4291