[PR #2525] [MERGED] Rework locking and eventing during startup and shutdown to alleviate some VT issues #24975

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2525
Author: @miniksa
Created: 8/24/2019
Status: Merged
Merged: 9/20/2019
Merged by: @miniksa

Base: masterHead: dev/miniksa/1810_attempt4


📝 Commits (10+)

  • e1e9961 try to acquire the lock and try to stop synchronous waits when triggering shutdown activities.
  • 4f2db78 get the actual thread handle and try to cancel it.
  • 2128268 rearrange the way that shutdown works completely for the VT threads. Remove extraneous attempts at cleanup.
  • 7f627e1 We've reached a point where the VT stuff unspools just fine. Now to figure out why everything else doesn't.
  • e136314 Add a series of events and functions that unspool when the last client leaves such that we can clean everything up appropriately.
  • e9290d6 Prevent race for the lock during console allocate by using a wink/nudge to tell the input thread it is allowed to operate under the lock the IO thread is holding. Without this, the signal thread breaking and shutting down may be able to acquire the lock in a split second and cause unexpected oddities to occur for shutting down console context while it is being allocated for a client.
  • 9021a5a Fix build failures because I didn't give the event to the unit tests.
  • 3b76cc4 code format run.
  • 767ceab signal on destruct. add the eventing appropriately to the unit tests so they don't hang forever.
  • 4bb890a Fix to manual reset events, try to debug.

📊 Changes

32 files changed (+732 additions, -288 deletions)

View changed files

📝 src/host/PtySignalInputThread.cpp (+22 -54)
📝 src/host/PtySignalInputThread.hpp (+5 -3)
📝 src/host/VtInputThread.cpp (+82 -38)
📝 src/host/VtInputThread.hpp (+11 -5)
📝 src/host/VtIo.cpp (+88 -65)
📝 src/host/VtIo.hpp (+7 -8)
src/host/ft_host/API_PtyTests.cpp (+244 -0)
📝 src/host/ft_host/Host.FeatureTests.vcxproj (+1 -0)
📝 src/host/ft_host/Host.FeatureTests.vcxproj.filters (+3 -0)
📝 src/host/ft_host/sources (+1 -0)
📝 src/host/globals.h (+2 -1)
📝 src/host/output.cpp (+12 -11)
📝 src/host/srvinit.cpp (+17 -8)
📝 src/host/ut_host/VtIoTests.cpp (+31 -4)
📝 src/host/ut_host/VtRendererTests.cpp (+23 -12)
src/inc/ITerminalOwner.hpp (+0 -33)
📝 src/inc/LibraryIncludes.h (+1 -0)
📝 src/interactivity/win32/windowio.cpp (+11 -7)
📝 src/interactivity/win32/windowproc.cpp (+49 -9)
📝 src/renderer/vt/WinTelnetEngine.cpp (+2 -1)

...and 12 more files

📄 Description

Summary of the Pull Request

Adjusts the startup and shutdown behavior of most threads in the console host to alleviate race conditions that are either exacerbated or introduced by the VT PTY threads.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed


🔄 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/2525 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 8/24/2019 **Status:** ✅ Merged **Merged:** 9/20/2019 **Merged by:** [@miniksa](https://github.com/miniksa) **Base:** `master` ← **Head:** `dev/miniksa/1810_attempt4` --- ### 📝 Commits (10+) - [`e1e9961`](https://github.com/microsoft/terminal/commit/e1e9961782c781181107903a786c867f4628d46b) try to acquire the lock and try to stop synchronous waits when triggering shutdown activities. - [`4f2db78`](https://github.com/microsoft/terminal/commit/4f2db783698e29f3950284f9b23184c0763d8b39) get the actual thread handle and try to cancel it. - [`2128268`](https://github.com/microsoft/terminal/commit/2128268028f9b213a3b7ff8e83bd360922cb6db6) rearrange the way that shutdown works completely for the VT threads. Remove extraneous attempts at cleanup. - [`7f627e1`](https://github.com/microsoft/terminal/commit/7f627e18d49bcce44b9ae38aad15ae0392928ed4) We've reached a point where the VT stuff unspools just fine. Now to figure out why everything else doesn't. - [`e136314`](https://github.com/microsoft/terminal/commit/e1363146ca4f46aa1855c7dd5b5dbfbdfcc74f06) Add a series of events and functions that unspool when the last client leaves such that we can clean everything up appropriately. - [`e9290d6`](https://github.com/microsoft/terminal/commit/e9290d61e49ba31a6d8e8a5f334a4ac2e7aa3160) Prevent race for the lock during console allocate by using a wink/nudge to tell the input thread it is allowed to operate under the lock the IO thread is holding. Without this, the signal thread breaking and shutting down may be able to acquire the lock in a split second and cause unexpected oddities to occur for shutting down console context while it is being allocated for a client. - [`9021a5a`](https://github.com/microsoft/terminal/commit/9021a5ac6d818c50b9b36415e0ff0d184d6a7c6d) Fix build failures because I didn't give the event to the unit tests. - [`3b76cc4`](https://github.com/microsoft/terminal/commit/3b76cc45a43d61ca404f1a0c12ab11d775ad8c94) code format run. - [`767ceab`](https://github.com/microsoft/terminal/commit/767ceab8198f046e6223c2a7b948707922406c8f) signal on destruct. add the eventing appropriately to the unit tests so they don't hang forever. - [`4bb890a`](https://github.com/microsoft/terminal/commit/4bb890a5b12dafa2667fb348707317a70c61f4f1) Fix to manual reset events, try to debug. ### 📊 Changes **32 files changed** (+732 additions, -288 deletions) <details> <summary>View changed files</summary> 📝 `src/host/PtySignalInputThread.cpp` (+22 -54) 📝 `src/host/PtySignalInputThread.hpp` (+5 -3) 📝 `src/host/VtInputThread.cpp` (+82 -38) 📝 `src/host/VtInputThread.hpp` (+11 -5) 📝 `src/host/VtIo.cpp` (+88 -65) 📝 `src/host/VtIo.hpp` (+7 -8) ➕ `src/host/ft_host/API_PtyTests.cpp` (+244 -0) 📝 `src/host/ft_host/Host.FeatureTests.vcxproj` (+1 -0) 📝 `src/host/ft_host/Host.FeatureTests.vcxproj.filters` (+3 -0) 📝 `src/host/ft_host/sources` (+1 -0) 📝 `src/host/globals.h` (+2 -1) 📝 `src/host/output.cpp` (+12 -11) 📝 `src/host/srvinit.cpp` (+17 -8) 📝 `src/host/ut_host/VtIoTests.cpp` (+31 -4) 📝 `src/host/ut_host/VtRendererTests.cpp` (+23 -12) ➖ `src/inc/ITerminalOwner.hpp` (+0 -33) 📝 `src/inc/LibraryIncludes.h` (+1 -0) 📝 `src/interactivity/win32/windowio.cpp` (+11 -7) 📝 `src/interactivity/win32/windowproc.cpp` (+49 -9) 📝 `src/renderer/vt/WinTelnetEngine.cpp` (+2 -1) _...and 12 more files_ </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Adjusts the startup and shutdown behavior of most threads in the console host to alleviate race conditions that are either exacerbated or introduced by the VT PTY threads. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [X] Closes #1810 * [X] I'm an employee * [X] Tests added/passed * [X] Requires documentation to be updated - Please see and review https://github.com/MicrosoftDocs/Console-Docs/pull/100 * [X] I'm a core contributor <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed --- <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:06:28 +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#24975