Crash when switching back from the alt buffer #17709
Labels
Area-Output
Related to output processing (inserting text into buffer, retrieving buffer text, etc.)
In-PR
This issue has a related PR
Issue-Bug
It either shouldn't be doing this or needs an investigation.
Needs-Tag-Fix
Doesn't match tag requirements
Product-Terminal
The new Windows Terminal.
Severity-Crash
Crashes are real bad news.
Milestone
Windows Terminal version
Commit edfa3ea
Windows build number
10.0.19045.4651
Other Software
No response
Steps to reproduce
It's not easy to reproduce, but I think all you really need to trigger the crash is to switch to the alt buffer with
printf "\e[?1049h"
, and then switch back to the main buffer withprintf "\e[?1049l"
.This is in Windows Terminal using a build that includes the new VT passthrough (PR #17510).
Expected Behavior
The terminal should not crash.
Actual Behavior
I got an access violation accessing the
screenInfo
parameter in theWriteCharsVT
function here:terminal/src/host/_stream.cpp
Line 353 in 0199ca3
What happens is that we first pass the
\e[?1049l
sequence through to conhost in thestateMachine.ProcessString
call a couple of lines above. That ends up callingSCREEN_INFORMATION::UseMainScreenBuffer
, which callss_RemoveScreenBuffer(psiAlt)
, which deletes the activescreenInfo
instance here:terminal/src/host/screenInfo.cpp
Line 231 in 0199ca3
That's the same
screenInfo
instance that was passed to ourWriteCharsVT
function, so when we later try to reference that, we're referencing a deleted object. Sometimes we get lucky and nothing bad happens, but sometimes it will crash.I think maybe all we need to do to prevent the crash is to save the
screenInfo.OutputMode
at the start of the function, and then use that saved value instead of trying to look it up via thescreenInfo
object.The text was updated successfully, but these errors were encountered: