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

Implement a timeout for PSEUDOCONSOLE_INHERIT_CURSOR #17574

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Jul 16, 2024

This implements a 3s timeout for cursor inheritance which prevents
ConPTY from being deadlocked at startup, if the terminal misbehaves.
It serves another purpose, however, in that it prepares the code for
the introduction of overlapped IO in #17510.

Closes #11213

@lhecker lhecker added the Product-Conpty For console issues specifically related to conpty label Jul 16, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Priority-1 A description (P1) labels Jul 16, 2024
return _encounteredWin32InputModeSequence;
// Technically we should decrement the timeout with each iteration,
// but I suspect infinite spurious wake-ups are a theoretical problem.
while (!_lookingForDSR.load(std::memory_order::relaxed))
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this condition need to go the other way? We want to atomic_wait while _lookingForDSR is true.

Copy link
Member

Choose a reason for hiding this comment

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

I've done my brain in trying to figure this out

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh look @zadjii-msft! Dustin found the actual source of the bug. 😅
It's not that it timeouts, but rather that it doesn't wait for the answer to begin with.

@@ -57,79 +43,67 @@ VtInputThread::VtInputThread(_In_ wil::unique_hfile hPipe,
// - The return value of the underlying instance's _InputThread
DWORD WINAPI VtInputThread::StaticVtInputThreadProc(_In_ LPVOID lpParameter)
{
const auto pInstance = reinterpret_cast<VtInputThread*>(lpParameter);
const auto pInstance = static_cast<VtInputThread*>(lpParameter);
Copy link
Member Author

Choose a reason for hiding this comment

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

The diff in this file is a lot smaller with suppressed whitespace changes: https://github.com/microsoft/terminal/pull/17574/files?w=1

@lhecker lhecker added this pull request to the merge queue Jul 16, 2024
@DHowett DHowett removed this pull request from the merge queue due to a manual request Jul 17, 2024
@lhecker lhecker merged commit 1ac221a into main Jul 17, 2024
20 checks passed
@lhecker lhecker deleted the dev/lhecker/17510-input-thread branch July 17, 2024 01:03
@lhecker lhecker mentioned this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Conpty For console issues specifically related to conpty
Projects
None yet
3 participants