[PR #13882] [MERGED] Fix a ControlCore race condition on connection close #29796

Open
opened 2026-01-31 09:36:57 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13882
Author: @lhecker
Created: 8/30/2022
Status: ✅ Merged
Merged: 9/6/2022
Merged by: @undefined

Base: main ← Head: dev/lhecker/13880-connection-close-race


📝 Commits (2)

  • 9cd5ea6 Fix a ControlCore race condition on connection close
  • 9ca1a19 Merge Dustin's feedback

📊 Changes

4 files changed (+12 additions, -48 deletions)

View changed files

📝 src/cascadia/TerminalConnection/AzureConnection.cpp (+4 -3)
📝 src/cascadia/TerminalConnection/ConptyConnection.cpp (+7 -10)
📝 src/cascadia/TerminalControl/ControlCore.cpp (+1 -33)
📝 src/cascadia/TerminalControl/ControlCore.h (+0 -2)

📄 Description

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 ✅

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/13882 **Author:** [@lhecker](https://github.com/lhecker) **Created:** 8/30/2022 **Status:** ✅ Merged **Merged:** 9/6/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/lhecker/13880-connection-close-race` --- ### 📝 Commits (2) - [`9cd5ea6`](https://github.com/microsoft/terminal/commit/9cd5ea6fef8d49371aa08f3fd5effced2af24a2e) Fix a ControlCore race condition on connection close - [`9ca1a19`](https://github.com/microsoft/terminal/commit/9ca1a19be8098c4885a7688fe4c11f6dfadd0b34) Merge Dustin's feedback ### 📊 Changes **4 files changed** (+12 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalConnection/AzureConnection.cpp` (+4 -3) 📝 `src/cascadia/TerminalConnection/ConptyConnection.cpp` (+7 -10) 📝 `src/cascadia/TerminalControl/ControlCore.cpp` (+1 -33) 📝 `src/cascadia/TerminalControl/ControlCore.h` (+0 -2) </details> ### 📄 Description 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 ✅ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:36:57 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29796