-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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 ControlCore race condition on connection close #13882
Conversation
ce0aa9c
to
9cd5ea6
Compare
I've asked Leonard for more tests:
|
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.
I'm not signing off so that we hold till 1.17, but treat this as a ✔️ if the baby arrives before the 1.16/1.17 fork
But also maybe test blatting |
Alright, I finished testing everything and updated the PR message. |
ONE FINAL TEST |
Nevermind I couldn't even get it to work normally. |
Could we get this into 1.16? I think this issue might be the cause for a crash on tab close I'm seeing quite often in debug builds... |
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.
Co-authored-by: Dustin L. Howett <[email protected]>
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
As noted by the `winrt::event` documentation: > [...] But for asynchronous events, even after revoking [...], an in-flight > event might reach your object after it has started destructing. This is because while adding/removing/calling event handlers might be thread-safe, there's no guarantee that they run mutually exclusive. This commit fixes the issue by reverting 6f0f245. Since we never checked the result of closing a terminal connection anyways, this commit simply drops the wait on the connection being teared down to ensure #1996 doesn't regress. Closes #13880 ## Validation Steps Performed * Open tab, close tab, open tab, close tab, open tab, close tab * ConPTY ✅ * Azure ✅ * Closing a tab with a huge amount of panes ✅ * Opening a bunch of tabs and then closing the window ✅ * Closing a tab while it's busy with VT ✅ * `wtd -w 0 nt cmd /c exit` ✅ * `wtd -w -1 cmd /c exit` * No WerFault spawns ✅ (cherry picked from commit 666c446) Service-Card-Id: 86178273 Service-Version: 1.15
🎉 Handy links: |
2 new ConPTY APIs were added as part of this commit: * `ClosePseudoConsoleTimeout` Complements `ClosePseudoConsole`, allowing users to override the `INFINITE` wait for OpenConsole to exit with any arbitrary timeout, including 0. * `ConptyReleasePseudoConsole` This releases the `\Reference` handle held by the `HPCON`. While it makes launching further PTY clients via `PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE` impossible, it does allow conhost/OpenConsole to exit naturally once all console clients have disconnected. This makes it unnecessary to having to monitor the exit of the spawned shell/application, just to then call `ClosePseudoConsole`, while carefully continuing to read from the output pipe. Instead users can now just read from the output pipe until it is closed, knowing for sure that no more data will come or clients connect. This is especially useful in combination with `ClosePseudoConsoleTimeout` and a timeout of 0, to allow conhost/OpenConsole to exit asynchronously. These new APIs are used to fix an array of bugs around Windows Terminal exiting either too early or too late. They also make usage of the ConPTY API simpler in most situations (when spawning a single application and waiting for it to exit). Depends on #13882, #14041, #14160, #14282 Closes #4564 Closes #14416 Closes MSFT-42244182 ## Validation Steps Performed * Calling `FreeConsole` in a handoff'd application closes the tab ✅ * Create a .bat file containing only `start /B cmd.exe`. If WT stable is the default terminal the tab closes instantly ✅ With these changes included the tab stays open with a cmd.exe prompt ✅ * New ConPTY tests ✅
As noted by the
winrt::event
documentation:This is because while adding/removing/calling event handlers might be
thread-safe, there's no guarantee that they run mutually exclusive.
This commit fixes the issue by reverting 6f0f245. Since we never checked
the result of closing a terminal connection anyways, this commit simply drops
the wait on the connection being teared down to ensure #1996 doesn't regress.
Closes #13880
Validation Steps Performed
wtd -w 0 nt cmd /c exit
✅wtd -w -1 cmd /c exit