[PR #13859] [MERGED] Fix a race condition in UpdatePatternLocations #29787

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

📋 Pull Request Information

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

Base: main ← Head: dev/lhecker/12607-workaround-2


📝 Commits (1)

  • 2268af5 Fix a race condition in UpdatePatternLocations

📊 Changes

3 files changed (+6 additions, -17 deletions)

View changed files

📝 src/cascadia/TerminalControl/ControlCore.cpp (+5 -14)
📝 src/cascadia/TerminalControl/ControlCore.h (+1 -2)
📝 src/cascadia/TerminalControl/ControlCore.idl (+0 -1)

📄 Description

Since locking the console can take a non-trivial amount of time,
the main thread might have already released the ControlCore instance, while the
UpdatePatternLocations background thread is holding the last active reference.
If the function call goes out of scope, we destroy the instance, which might
not be safe, considering its members are usually only used by the main thread.
This commit fixes the issue by only holding a reference of the Terminal.

Validation Steps Performed

  • Patterns are recognized ✅

🔄 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/13859 **Author:** [@lhecker](https://github.com/lhecker) **Created:** 8/26/2022 **Status:** ✅ Merged **Merged:** 8/30/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/lhecker/12607-workaround-2` --- ### 📝 Commits (1) - [`2268af5`](https://github.com/microsoft/terminal/commit/2268af52f924c17bc2827a286c1e29a205723443) Fix a race condition in UpdatePatternLocations ### 📊 Changes **3 files changed** (+6 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/ControlCore.cpp` (+5 -14) 📝 `src/cascadia/TerminalControl/ControlCore.h` (+1 -2) 📝 `src/cascadia/TerminalControl/ControlCore.idl` (+0 -1) </details> ### 📄 Description Since locking the console can take a non-trivial amount of time, the main thread might have already released the ControlCore instance, while the `UpdatePatternLocations` background thread is holding the last active reference. If the function call goes out of scope, we destroy the instance, which might not be safe, considering its members are usually only used by the main thread. This commit fixes the issue by only holding a reference of the `Terminal`. ## Validation Steps Performed * Patterns are recognized ✅ --- <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:53 +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#29787