mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-20 05:54:23 +00:00
Fix a crash in _WritePseudoWindowCallback (#13777)
Fixes MSFT:40853556
There's a small race here. The renderer thread in ConPTY might notice the terminal is gone, call CloseOutput, and release the vt renderer, and then the window proc fires and decides to minimize/restore the window, triggering an A/V.
I'm 100% confident that this has NEVER happened to a real user. But the test labs hit it so much that it makes up ~26% of our crashes.
I haven't tested this cause again, _it doesn't hit in the wild_
(cherry picked from commit f58240c9c0)
Service-Card-Id: 85103518
Service-Version: 1.15
This commit is contained in:
committed by
Dustin Howett
parent
f2a691863b
commit
038ad3b509
@@ -258,8 +258,20 @@ bool VtIo::IsUsingVt() const
|
||||
g.getConsoleInformation().GetActiveOutputBuffer().SetTerminalConnection(_pVtRenderEngine.get());
|
||||
g.getConsoleInformation().GetActiveInputBuffer()->SetTerminalConnection(_pVtRenderEngine.get());
|
||||
ServiceLocator::SetPseudoWindowCallback([&](bool showOrHide) -> void {
|
||||
// Set the remote window visibility to the request
|
||||
LOG_IF_FAILED(_pVtRenderEngine->SetWindowVisibility(showOrHide));
|
||||
// MSFT:40853556 Grab the shutdown lock here, so that another
|
||||
// thread can't trigger a CloseOutput and release the
|
||||
// _pVtRenderEngine out from underneath us.
|
||||
//
|
||||
// I'm doing this instead of just
|
||||
// SetPseudoWindowCallback(nullptr), so that we don't just move
|
||||
// the A/V race to in between checking
|
||||
// _pseudoWindowMessageCallback and actually calling it.
|
||||
std::lock_guard<std::mutex> lk(_shutdownLock);
|
||||
if (_pVtRenderEngine)
|
||||
{
|
||||
// Set the remote window visibility to the request
|
||||
LOG_IF_FAILED(_pVtRenderEngine->SetWindowVisibility(showOrHide));
|
||||
}
|
||||
});
|
||||
}
|
||||
CATCH_RETURN();
|
||||
|
||||
Reference in New Issue
Block a user