[PR #14694] [MERGED] Add mutex to keyEvents in TermControlAutomationPeer #30208

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/14694
Author: @carlos-zamora
Created: 1/17/2023
Status: Merged
Merged: 1/18/2023
Merged by: @undefined

Base: mainHead: dev/cazamor/key-events-race


📝 Commits (1)

  • 1ea4739 Add mutex to keyEvents in TermControlAutomationPeer

📊 Changes

3 files changed (+24 additions, -20 deletions)

View changed files

📝 src/cascadia/TerminalControl/TermControlAutomationPeer.cpp (+22 -19)
📝 src/cascadia/TerminalControl/TermControlAutomationPeer.h (+1 -1)
📝 src/cascadia/TerminalControl/pch.h (+1 -0)

📄 Description

Some investigation revealed that _keyEvents would get a NULL_POINTER_READ error. On the main thread, RecordKeyEvent() would be called, which mainly updates _keyEvents. On the renderer thread, NotifyNewOutput() would be called, which starts by iterating through _keyEvents and slowly clearing it out. On occasion, these two threads are modifying _keyEvents simultaneously, causing a crash.

The fix is to add a mutex on this variable.

Closes #14592


🔄 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/14694 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 1/17/2023 **Status:** ✅ Merged **Merged:** 1/18/2023 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/cazamor/key-events-race` --- ### 📝 Commits (1) - [`1ea4739`](https://github.com/microsoft/terminal/commit/1ea4739c17c8ed2d8ea44b8e10144b741e1702a7) Add mutex to keyEvents in TermControlAutomationPeer ### 📊 Changes **3 files changed** (+24 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TermControlAutomationPeer.cpp` (+22 -19) 📝 `src/cascadia/TerminalControl/TermControlAutomationPeer.h` (+1 -1) 📝 `src/cascadia/TerminalControl/pch.h` (+1 -0) </details> ### 📄 Description Some investigation revealed that `_keyEvents` would get a `NULL_POINTER_READ` error. On the main thread, `RecordKeyEvent()` would be called, which mainly updates `_keyEvents`. On the renderer thread, `NotifyNewOutput()` would be called, which starts by iterating through `_keyEvents` and slowly clearing it out. On occasion, these two threads are modifying `_keyEvents` simultaneously, causing a crash. The fix is to add a mutex on this variable. Closes #14592 --- <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:39:20 +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#30208