Opening a hyperlink can cause the Terminal to hang #11097

Open
opened 2026-01-31 02:38:31 +00:00 by claunia · 0 comments
Owner

Originally created by @zadjii-msft on GitHub (Oct 21, 2020).

Originally assigned to: @miniksa on GitHub.

I originally posted this in #7691, but it turns out the hang wasn't even introduced there - it was already in main before that.


Blocking based off the hang discussion we're currently having on teams. Turns out the main thread is grabbing the write lock twice:

Once in

[0x4f] TerminalControl!winrt::Microsoft::Terminal::TerminalControl::implementation::TermControl::_PointerPressedHandler + 0x593

then again in

[0x6]   TerminalControl!winrt::Microsoft::Terminal::TerminalControl::implementation::TermControl::_TrySendKeyEvent + 0x116   

because WinUI somehow routes a KeyDownEvent to TermControl during the PointerPressed???


Suggested fix:

if (point.Properties().IsLeftButtonPressed())
{
    const auto cursorPosition = point.Position();
    const auto terminalPosition = _GetTerminalPosition(cursorPosition);
    {
        // handle ALT key
        auto lock = _terminal->LockForWriting();
        _terminal->SetBlockSelection(altEnabled);
        // Release the write lock
    }
    // Re-grab the read lock
    auto lock = _terminal->LockForReading();
    ...
}
Originally created by @zadjii-msft on GitHub (Oct 21, 2020). Originally assigned to: @miniksa on GitHub. I originally posted this in #7691, but it turns out the hang wasn't even introduced there - it was already in `main` before that. <hr> Blocking based off the hang discussion we're currently having on teams. Turns out the main thread is grabbing the write lock twice: Once in ``` [0x4f] TerminalControl!winrt::Microsoft::Terminal::TerminalControl::implementation::TermControl::_PointerPressedHandler + 0x593 ``` then again in ``` [0x6] TerminalControl!winrt::Microsoft::Terminal::TerminalControl::implementation::TermControl::_TrySendKeyEvent + 0x116 ``` because WinUI somehow routes a `KeyDownEvent` to TermControl _during the `PointerPressed`???_ <hr> Suggested fix: ```c++ if (point.Properties().IsLeftButtonPressed()) { const auto cursorPosition = point.Position(); const auto terminalPosition = _GetTerminalPosition(cursorPosition); { // handle ALT key auto lock = _terminal->LockForWriting(); _terminal->SetBlockSelection(altEnabled); // Release the write lock } // Re-grab the read lock auto lock = _terminal->LockForReading(); ... } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11097