[PR #8087] Fire and forget Hyperlink handling to break deadlock #27096

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

Original Pull Request: https://github.com/microsoft/terminal/pull/8087

State: closed
Merged: Yes


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.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/8087 **State:** closed **Merged:** Yes --- 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.
claunia added the pull-request label 2026-01-31 09:19:58 +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#27096