[PR #13859] Fix a race condition in UpdatePatternLocations #29792

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

Original Pull Request: https://github.com/microsoft/terminal/pull/13859

State: closed
Merged: Yes


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
**Original Pull Request:** https://github.com/microsoft/terminal/pull/13859 **State:** closed **Merged:** Yes --- 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 ✅
claunia added the pull-request label 2026-01-31 09:36:55 +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#29792