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

[deadlock fix] Remove lock for SIUP::GetSelectionRange() #11386

Merged
1 commit merged into from
Sep 30, 2021

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Sep 30, 2021

Summary of the Pull Request

The deadlock was caused by ScreenInfoUiaProviderBase::GetSelection() calling TermControlUiaProvider::GetSelectionRange (both of which attempted to lock the console). This PR removes the lock and initialization check from TermControlUiaProvider. It is no longer necessary because the only one that calls it is SIUPB::GetSelection().

Additionally, this adds some code that was useful in debugging this race condition. That should help us figure out any locking issues that may come up in the future.

References

#11312
Closes #11385

Validation Steps Performed

✅ Repro steps don't cause hang

@carlos-zamora carlos-zamora added zStable-Service-Queued-1.12 A floating label that tracks the current Stable version for servicing purposes. zPreview-Service-Queued-1.13 A floating label that tracks the current Preview version for servicing purposes. labels Sep 30, 2021
@ghost ghost added Area-Accessibility Issues related to accessibility Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree. Severity-Crash Crashes are real bad news. labels Sep 30, 2021
@@ -849,7 +849,13 @@ WORD Terminal::_TakeVirtualKeyFromLastKeyEvent(const WORD scanCode) noexcept
// will release this lock when it's destructed.
[[nodiscard]] std::unique_lock<til::ticket_lock> Terminal::LockForReading()
{
#ifdef NDEBUG
Copy link
Member

Choose a reason for hiding this comment

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

I've always done ifdef DBG and done it the other way. @lhecker would know if this is fine.

@carlos-zamora carlos-zamora added AutoMerge Marked for automatic merge by the bot when requirements are met and removed zStable-Service-Queued-1.12 A floating label that tracks the current Stable version for servicing purposes. labels Sep 30, 2021
@ghost
Copy link

ghost commented Sep 30, 2021

Hello @carlos-zamora!

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.

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

@carlos-zamora
Copy link
Member Author

@msftbot merge this in 1 minute

@ghost
Copy link

ghost commented Sep 30, 2021

Hello @carlos-zamora!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Thu, 30 Sep 2021 22:14:35 GMT, which is in 1 minute

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@ghost ghost merged commit 6657d2c into main Sep 30, 2021
@ghost ghost deleted the dev/cazamor/a11y/bugfix-selection-crashes branch September 30, 2021 22:15
carlos-zamora added a commit that referenced this pull request Sep 30, 2021
## Summary of the Pull Request
The deadlock was caused by `ScreenInfoUiaProviderBase::GetSelection()` calling `TermControlUiaProvider::GetSelectionRange` (both of which attempted to lock the console). This PR removes the lock and initialization check from `TermControlUiaProvider`. It is no longer necessary because the only one that calls it is `SIUPB::GetSelection()`.

Additionally, this adds some code that was useful in debugging this race condition. That should help us figure out any locking issues that may come up in the future.

## References
#11312
Closes #11385 

## Validation Steps Performed
✅ Repro steps don't cause hang
@ghost
Copy link

ghost commented Oct 4, 2021

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

Handy links:

@DHowett DHowett removed the zPreview-Service-Queued-1.13 A floating label that tracks the current Preview version for servicing purposes. label Oct 11, 2021
@ghost
Copy link

ghost commented Oct 20, 2021

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

Handy links:

@ghost
Copy link

ghost commented Oct 20, 2021

🎉Windows Terminal Preview v1.12.2922.0 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
Area-Accessibility Issues related to accessibility AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree. Severity-Crash Crashes are real bad news.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open narrator, select some text in the Terminal ---> experience a hang
4 participants