Rare hang / infinite loop writing line containing emoji unicode characters #18897
Labels
Area-Output
Related to output processing (inserting text into buffer, retrieving buffer text, etc.)
Issue-Bug
It either shouldn't be doing this or needs an investigation.
Priority-1
A description (P1)
Product-Conhost
For issues in the Console codebase
Product-Terminal
The new Windows Terminal.
Windows Terminal version
1.22.11141.0
Windows build number
10.0.26100.3775
Other Software
Output coming from a node.js script
Steps to reproduce
Unfortunately I cannot reproduce this consistently. I had noticed this hanging on occasion, and would have to close the window, and OpenConsole.exe would remain spinning a core until I terminated the process. Eventually I decided to grab a full memory dump file next time it occurred, though I have not been able to reproduce again. I do still have the full memory dump available.
The underlying node.js script is simply logging operations to the console.
In this case, it is writing the text: "countByTag 🎵 Oblivion - Grimes [1]: 0.215ms\r\n"
Expected Behavior
Text should output without hanging the console.
Actual Behavior
The console hangs and becomes unresponsive. A simple analysis of the memory dump follows:
OpenConsole!WriteCharsLegacy is writing the text "countByTag 🎵 Oblivion - Grimes [1]: 0.215ms\r\n"
this calls _writeCharsLegacyUnprocessed which appears to get stuck in the while loop
while (!state.text.empty())
Presumably the first textBuffer.Replace call in this loop succeeds, because by the time there is a hang the state has advanced to the first emoji character in the string; that is, state.text is now pointing to the first emoji / unicode character in the text: "🎵 Oblivion - Grimes [1]: 0.215ms\r\n"
Note that the emoji is made of two unicode chars, which I have a hunch is the underlying issue.
state.columnBegin is 126, .columnLimit is 127, columnEnd is 127, columnBeginDirty is 126, columnEndDirty is 127 (all decimal numbers here). The TextBuffer.width is also 127
I grabbed two dumps a few seconds apart and both are in pretty much the same area, one was in ROW::WriteHelper::Finish and one was ROW::ReplaceText, but notably there does not seem to be any change/progress in the state variable.
I think somehow textBuffer.Replace is not advancing the text for some reason due to an edge case here, which causes it to never be empty, and therefore spin forever.
I can provide a dump file securely if desired.
stack trace:
The text was updated successfully, but these errors were encountered: