[PR #14041] [MERGED] Fix potential lags/deadlocks during tab close #29896

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/14041
Author: @lhecker
Created: 9/20/2022
Status: Merged
Merged: 9/21/2022
Merged by: @undefined

Base: mainHead: dev/lhecker/14032-close-lag


📝 Commits (4)

📊 Changes

9 files changed (+73 additions, -44 deletions)

View changed files

📝 src/cascadia/TerminalConnection/ConptyConnection.cpp (+17 -7)
📝 src/cascadia/TerminalConnection/ConptyConnection.h (+1 -1)
📝 src/inc/conpty-static.h (+2 -0)
📝 src/interactivity/base/ServiceLocator.cpp (+19 -2)
📝 src/interactivity/inc/ServiceLocator.hpp (+1 -4)
📝 src/winconpty/dll/winconpty.def (+1 -0)
📝 src/winconpty/ft_pty/ConPtyTests.cpp (+10 -10)
📝 src/winconpty/winconpty.cpp (+21 -18)
📝 src/winconpty/winconpty.h (+1 -2)

📄 Description

ConptyClosePseudoConsole blocks until OpenConsole exits.
This is problematic for the changes in 666c446, which stopped calling that
function on a background thread to solve a race condition. This commit fixes
the potential lags/deadlocks from waiting on OpenConsole's exit, by adding
ConptyClosePseudoConsoleNoWait which only closes the IO handles and allows
OpenConsole to exit naturally. This uncovered another potential deadlock
in ServiceLocator::RundownAndExit which might call itself recursively.

Closes #14032

Validation Steps Performed

  • Print tons of text and concurrently close the tab.
    Tab closes, OpenConsole/pwsh exits instantly
  • Use Enter-VsDevShell and close the tab.
    Tab closes instantly, OpenConsole/pwsh exits after ~5 seconds

🔄 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/14041 **Author:** [@lhecker](https://github.com/lhecker) **Created:** 9/20/2022 **Status:** ✅ Merged **Merged:** 9/21/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/lhecker/14032-close-lag` --- ### 📝 Commits (4) - [`2f09d15`](https://github.com/microsoft/terminal/commit/2f09d15593c994b555eefb7841e5b461d84e1e75) Fix potential lags/deadlocks during tab close - [`8301e45`](https://github.com/microsoft/terminal/commit/8301e45dd2b363d26be656abdf76862b5b7cd2a0) Fix AuditMode errors - [`e4bccbf`](https://github.com/microsoft/terminal/commit/e4bccbf0ab7192d24332def3c550a5762d6f75bd) Address feedback - [`f142bb9`](https://github.com/microsoft/terminal/commit/f142bb98833d34a7cb1772e845ec249f5d8ae6d7) Address feedback ### 📊 Changes **9 files changed** (+73 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalConnection/ConptyConnection.cpp` (+17 -7) 📝 `src/cascadia/TerminalConnection/ConptyConnection.h` (+1 -1) 📝 `src/inc/conpty-static.h` (+2 -0) 📝 `src/interactivity/base/ServiceLocator.cpp` (+19 -2) 📝 `src/interactivity/inc/ServiceLocator.hpp` (+1 -4) 📝 `src/winconpty/dll/winconpty.def` (+1 -0) 📝 `src/winconpty/ft_pty/ConPtyTests.cpp` (+10 -10) 📝 `src/winconpty/winconpty.cpp` (+21 -18) 📝 `src/winconpty/winconpty.h` (+1 -2) </details> ### 📄 Description `ConptyClosePseudoConsole` blocks until OpenConsole exits. This is problematic for the changes in 666c446, which stopped calling that function on a background thread to solve a race condition. This commit fixes the potential lags/deadlocks from waiting on OpenConsole's exit, by adding `ConptyClosePseudoConsoleNoWait` which only closes the IO handles and allows OpenConsole to exit naturally. This uncovered another potential deadlock in `ServiceLocator::RundownAndExit` which might call itself recursively. Closes #14032 ## Validation Steps Performed * Print tons of text and concurrently close the tab. Tab closes, OpenConsole/pwsh exits instantly ✅ * Use `Enter-VsDevShell` and close the tab. Tab closes instantly, OpenConsole/pwsh exits after ~5 seconds ✅ --- <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:37:30 +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#29896