Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash when disabling the ASB #17748

Merged
merged 1 commit into from
Aug 20, 2024
Merged

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Aug 20, 2024

ProcessString may delete the ASB and cause a dangling screen info
pointer. As such, we must avoid using the pointer after the call.

Closes #17709

Validation Steps Performed

I couldn't repro the issue.

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news. labels Aug 20, 2024
@@ -336,6 +336,9 @@ void WriteCharsVT(SCREEN_INFORMATION& screenInfo, const std::wstring_view& str)
{
auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
auto& stateMachine = screenInfo.GetStateMachine();
// If the given screenInfo is the alternate screen buffer, disabling the alternate screen buffer in this
// VT payload will cause the pointer to be invalidated. We thus need to get all the information we need now.
const auto disableNewlineTranslation = WI_IsFlagSet(screenInfo.OutputMode, DISABLE_NEWLINE_AUTO_RETURN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const auto disableNewlineTranslation = WI_IsFlagSet(screenInfo.OutputMode, DISABLE_NEWLINE_AUTO_RETURN);
const auto disableNewlineTranslation = WI_IsFlagSet(screenInfo.OutputMode, DISABLE_NEWLINE_AUTO_RETURN);
wil::hide_name screenInfo;

May be worth considering? If it will compile.

I mean, but you'd need to do it below 344.

@lhecker lhecker merged commit 249fe2a into main Aug 20, 2024
20 checks passed
@lhecker lhecker deleted the dev/lhecker/17709-asb-crash branch August 20, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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. Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when switching back from the alt buffer
3 participants