Skip to content
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

Fix a race condition in CTerminalHandoff::s_StopListening #13410

Merged
1 commit merged into from
Jul 5, 2022

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Jul 1, 2022

This commit fixes a minor race condition covered as part of #13368.
The member _pfnHandoff was read without the mutex _mtx being locked first.
The issue was solved by acquiring the lock early and running the entire
s_StopListening function with that lock held.

s_StopListening();

std::unique_lock lock{ _mtx };
LOG_IF_FAILED(s_StopListeningLocked());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this change is correct (i.e. holding the lock while calling s_StopListening).
Previously, s_StopListening would acquire the lock itself, so nothing has effectively changed here.

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jul 5, 2022
@ghost
Copy link

ghost commented Jul 5, 2022

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 95a1962 into main Jul 5, 2022
@ghost ghost deleted the dev/lhecker/race-condition branch July 5, 2022 20:25
DHowett pushed a commit that referenced this pull request Jul 5, 2022
This commit fixes a minor race condition covered as part of #13368.
The member `_pfnHandoff` was read without the mutex `_mtx` being locked first.
The issue was solved by acquiring the lock early and running the entire
`s_StopListening` function with that lock held.

(cherry picked from commit 95a1962)
Service-Card-Id: 83893125
Service-Version: 1.14
DHowett pushed a commit that referenced this pull request Jul 5, 2022
This commit fixes a minor race condition covered as part of #13368.
The member `_pfnHandoff` was read without the mutex `_mtx` being locked first.
The issue was solved by acquiring the lock early and running the entire
`s_StopListening` function with that lock held.

(cherry picked from commit 95a1962)
Service-Card-Id: 83893126
Service-Version: 1.15
@ghost
Copy link

ghost commented Jul 6, 2022

🎉Windows Terminal v1.14.186 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Jul 6, 2022

🎉Windows Terminal Preview v1.15.186 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants