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

Fire and forget Hyperlink handling to break deadlock #8087

Merged
2 commits merged into from
Oct 29, 2020

Conversation

miniksa
Copy link
Member

@miniksa miniksa commented Oct 28, 2020

Fire and forget on the hyperlink handler inside the TermControl.

PR Checklist

Detailed Description of the Pull Request / Additional comments

In TermControl, _HyperlinkHandler is called by
_PointerPressedHandler which has taken a write lock for all its
friends. However, _HyperlinkHandler downstreams to ShellExecute
which can pump the message queue looking for something. That pumping of
the queue can trigger messages that also want the write lock to update
state. They get stuck. Everything hangs.

_HyperlinkHandler really only needs read lock and really only for as
long as it takes to fill up its parameters before it's invoked... but
the simpler and more contained solution is to just fire and forget the
rest of the method that causes the deadlock to a continuation at the
tail of the dispatcher queue so _PointerPressedHandler can complete
and naturally drop the write lock.

Validation Steps Performed

  • Launched main manually on my box and clicked the hyperlink that is
    detected when Powershell starts and it froze.
  • Launched this change manually on my box and clicked the hyperlink that
    is detected when Powershell starts and it did not freeze.

@miniksa miniksa added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Severity-Crash Crashes are real bad news. Product-Terminal The new Windows Terminal. labels Oct 28, 2020
@miniksa miniksa self-assigned this Oct 28, 2020
@ghost ghost added Priority-0 Bugs that we consider release-blocking/recall-class (P0) Severity-Blocking We won't ship a release like this! No-siree. labels Oct 28, 2020
@DHowett
Copy link
Member

DHowett commented Oct 29, 2020

Over to @PankajBhojwani for another signoff in the morning 😄

@DHowett DHowett assigned PankajBhojwani and unassigned miniksa Oct 29, 2020
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Yea that'll work

@zadjii-msft
Copy link
Member

@msftbot make sure @PankajBhojwani signs off on this

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 29, 2020
@ghost
Copy link

ghost commented Oct 29, 2020

Hello @zadjii-msft!

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:

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".

Copy link
Contributor

@PankajBhojwani PankajBhojwani left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

@ghost ghost merged commit 2ea4742 into main Oct 29, 2020
@ghost ghost deleted the dev/miniksa/you_link_me_right_round branch October 29, 2020 14:03
DHowett pushed a commit that referenced this pull request Nov 3, 2020
Fire and forget on the hyperlink handler inside the TermControl.

## PR Checklist
* [x] Closes #7994
* [x] Tested manually
* [x] Hi, I work here.

## Detailed Description of the Pull Request / Additional comments
In `TermControl`, `_HyperlinkHandler` is called by
`_PointerPressedHandler` which has taken a write lock for all its
friends. However, `_HyperlinkHandler` downstreams to `ShellExecute`
which can pump the message queue looking for something. That pumping of
the queue can trigger messages that also want the write lock to update
state. They get stuck. Everything hangs.

`_HyperlinkHandler` really only needs read lock and really only for as
long as it takes to fill up its parameters before it's invoked... but
the simpler and more contained solution is to just fire and forget the
rest of the method that causes the deadlock to a continuation at the
tail of the dispatcher queue so `_PointerPressedHandler` can complete
and naturally drop the write lock.

## Validation Steps Performed
- Launched `main` manually on my box and clicked the hyperlink that is
  detected when Powershell starts and it froze.
- Launched this change manually on my box and clicked the hyperlink that
  is detected when Powershell starts and it did not freeze.

(cherry picked from commit 2ea4742)
@ghost
Copy link

ghost commented Nov 11, 2020

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

Handy links:

@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal Preview v1.5.3142.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-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) 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. Priority-0 Bugs that we consider release-blocking/recall-class (P0) 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.

Opening a hyperlink can cause the Terminal to hang
4 participants