-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mutex to keyEvents in TermControlAutomationPeer #14694
Conversation
@@ -112,7 +112,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
{ | |||
if (const auto keyEventChar{ gsl::narrow_cast<wchar_t>(charCode) }; IsReadable({ &keyEventChar, 1 })) | |||
{ | |||
_keyEvents.emplace_back(keyEventChar); | |||
_keyEvents.lock()->emplace_back(keyEventChar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lhecker this is an acceptable use of lock(), right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the guard should get destroyed at ;
(= after the insertion finished).
_keyEvents.pop_front(); | ||
} | ||
else | ||
auto keyEvents = _keyEvents.lock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, but this returns a proxy object... so really it doesn't matter. You're actually using a guard<deque>
, which is fine. Ignore me! You have not been bitten by C++; in fact, I have!
_keyEvents.pop_front(); | ||
} | ||
else | ||
auto keyEvents = _keyEvents.lock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @DHowett! Because this pull request has the Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 7 hours 43 minutes. No worries though, I will be back when the time is right! 😉 p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
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 (cherry picked from commit 8e04169) Service-Card-Id: 87649541 Service-Version: 1.16
🎉 Handy links: |
🎉 Handy links: |
Some investigation revealed that
_keyEvents
would get aNULL_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