-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 deadlock during ConPTY shutdown #14160
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,8 @@ VtIo::VtIo() : | |
auto& globals = ServiceLocator::LocateGlobals(); | ||
|
||
const auto& gci = globals.getConsoleInformation(); | ||
// SetWindowVisibility uses the console lock to protect access to _pVtRenderEngine. | ||
assert(gci.IsConsoleLocked()); | ||
|
||
try | ||
{ | ||
|
@@ -337,6 +339,11 @@ void VtIo::CreatePseudoWindow() | |
|
||
void VtIo::SetWindowVisibility(bool showOrHide) noexcept | ||
{ | ||
auto& gci = ::Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().getConsoleInformation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, i am suddenly worried this is a deadlock factory. We call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous code already acquired the console lock here. All I did was move the if condition inside the locked area. If we have such a bug then we should have had it before this PR is/was merged. |
||
|
||
gci.LockConsole(); | ||
auto unlock = wil::scope_exit([&] { gci.UnlockConsole(); }); | ||
|
||
// ConsoleInputThreadProcWin32 calls VtIo::CreatePseudoWindow, | ||
// which calls CreateWindowExW, which causes a WM_SIZE message. | ||
// In short, this function might be called before _pVtRenderEngine exists. | ||
|
@@ -346,11 +353,6 @@ void VtIo::SetWindowVisibility(bool showOrHide) noexcept | |
return; | ||
} | ||
|
||
auto& gci = ::Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().getConsoleInformation(); | ||
|
||
gci.LockConsole(); | ||
auto unlock = wil::scope_exit([&] { gci.UnlockConsole(); }); | ||
|
||
LOG_IF_FAILED(_pVtRenderEngine->SetWindowVisibility(showOrHide)); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI
_InputThread
is now[[noreturn]]
becauseCloseInput
is[[noreturn]]
. Hence, noreturn
is needed, despite this function "returning" aDWORD
.