[1.21.1091 Canary] Terminal crashes on launch #21554

Closed
opened 2026-01-31 07:48:00 +00:00 by claunia · 5 comments
Owner

Originally created by @zadjii-msft on GitHub (Apr 19, 2024).

Methinks it's an explosion in the merge between #16611 and #17067

Useless stack:

[0x3]   Microsoft_Terminal_Control!std::coroutine_traits<winrt::fire_and_forget,winrt::Microsoft::Terminal::Control::implementation::ControlCore &,std::basic_string_view<wchar_t,std::char_traits<wchar_t> >,unsigned int>::promise_type::unhandled_exception+0x9   0x61c3efc640   0x7fffe5b3a496   
[0x4]   Microsoft_Terminal_Control!`winrt::Microsoft::Terminal::Control::implementation::TermControl::_coreUpdateSearchResults$_ResumeCoro$1'::`1'::catch$57+0x26   0x61c3efc670   0x7fffe5b2fcd0   
[0x5]   Microsoft_Terminal_Control!_CallSettingFrame_LookupContinuationIndex+0x20   0x61c3efc6b0   0x7fffe5b2edf5   
[0x6]   Microsoft_Terminal_Control!__FrameHandler4::CxxCallCatchBlock+0x115   0x61c3efc6e0   0x7ff812f61d16   
[0x7]   ntdll!RtlCaptureContext2+0x4a6   0x61c3efc7c0   0x7fffe5b39fc8   
[0x8]   Microsoft_Terminal_Control!winrt::Microsoft::Terminal::Control::implementation::TermControl::_coreUpdateSearchResults$_ResumeCoro$1+0x278   0x61c3efee90   0x7fffe5b02170   
[0x9]   Microsoft_Terminal_Control!std::coroutine_handle<void>::resume+0xc   0x61c3efefd0   0x7ffff41d08f3   
[0xa]   Microsoft_Terminal_Control!wil::details::dispatcher_handler::Complete+0x1c   0x61c3efefd0   0x7ffff41d08f3   
[0xb]   Microsoft_Terminal_Control!wil::details::dispatcher_handler::operator()+0x1c   0x61c3efefd0   0x7ffff41d08f3   
[0xc]   Microsoft_Terminal_Control!winrt::impl::delegate<winrt::Windows::UI::Core::DispatchedHandler,wil::details::dispatcher_handler>::Invoke+0x20   0x61c3efefd0   0x7ffff41d08f3  

4e7b63c664/src/cascadia/TerminalControl/TermControl.cpp (L3569-L3595)

Originally created by @zadjii-msft on GitHub (Apr 19, 2024). Methinks it's an explosion in the merge between #16611 and #17067 Useless stack: ``` [0x3] Microsoft_Terminal_Control!std::coroutine_traits<winrt::fire_and_forget,winrt::Microsoft::Terminal::Control::implementation::ControlCore &,std::basic_string_view<wchar_t,std::char_traits<wchar_t> >,unsigned int>::promise_type::unhandled_exception+0x9 0x61c3efc640 0x7fffe5b3a496 [0x4] Microsoft_Terminal_Control!`winrt::Microsoft::Terminal::Control::implementation::TermControl::_coreUpdateSearchResults$_ResumeCoro$1'::`1'::catch$57+0x26 0x61c3efc670 0x7fffe5b2fcd0 [0x5] Microsoft_Terminal_Control!_CallSettingFrame_LookupContinuationIndex+0x20 0x61c3efc6b0 0x7fffe5b2edf5 [0x6] Microsoft_Terminal_Control!__FrameHandler4::CxxCallCatchBlock+0x115 0x61c3efc6e0 0x7ff812f61d16 [0x7] ntdll!RtlCaptureContext2+0x4a6 0x61c3efc7c0 0x7fffe5b39fc8 [0x8] Microsoft_Terminal_Control!winrt::Microsoft::Terminal::Control::implementation::TermControl::_coreUpdateSearchResults$_ResumeCoro$1+0x278 0x61c3efee90 0x7fffe5b02170 [0x9] Microsoft_Terminal_Control!std::coroutine_handle<void>::resume+0xc 0x61c3efefd0 0x7ffff41d08f3 [0xa] Microsoft_Terminal_Control!wil::details::dispatcher_handler::Complete+0x1c 0x61c3efefd0 0x7ffff41d08f3 [0xb] Microsoft_Terminal_Control!wil::details::dispatcher_handler::operator()+0x1c 0x61c3efefd0 0x7ffff41d08f3 [0xc] Microsoft_Terminal_Control!winrt::impl::delegate<winrt::Windows::UI::Core::DispatchedHandler,wil::details::dispatcher_handler>::Invoke+0x20 0x61c3efefd0 0x7ffff41d08f3 ``` https://github.com/microsoft/terminal/blob/4e7b63c664bc09da3ba2f08287cf03d3729ce3a2/src/cascadia/TerminalControl/TermControl.cpp#L3569-L3595
claunia added the Needs-TriageNeeds-Tag-FixSeverity-Blocking labels 2026-01-31 07:48:01 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Apr 19, 2024):

Okay first off: The automationPeer.RaiseNotificationEvent gets called... a lot, on startup. Before I've even opened the window. Shouldn't that get moved into if (_searchbox)?

@zadjii-msft commented on GitHub (Apr 19, 2024): Okay first off: The `automationPeer.RaiseNotificationEvent` gets called... a lot, on startup. Before I've even opened the window. Shouldn't that get moved into `if (_searchbox)`?
Author
Owner

@lhecker commented on GitHub (Apr 19, 2024):

We've discussed this over here: https://github.com/microsoft/terminal/pull/16611#discussion_r1569158640
I've just started making the changes necessary to fix that.

@lhecker commented on GitHub (Apr 19, 2024): We've discussed this over here: https://github.com/microsoft/terminal/pull/16611#discussion_r1569158640 I've just started making the changes necessary to fix that.
Author
Owner

@zadjii-msft commented on GitHub (Apr 19, 2024):

Mmk, lemme know when you've got a fix ready.

My half assed fix was:

diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp
index acab82931..1692a981a 100644
--- a/src/cascadia/TerminalControl/TermControl.cpp
+++ b/src/cascadia/TerminalControl/TermControl.cpp
@@ -3569,19 +3569,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation
     winrt::fire_and_forget TermControl::_coreUpdateSearchResults(const IInspectable& /*sender*/, Control::UpdateSearchResultsEventArgs args)
     {
         co_await wil::resume_foreground(Dispatcher());
-        if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(*this) })
-        {
-            automationPeer.RaiseNotificationEvent(
-                Automation::Peers::AutomationNotificationKind::ActionCompleted,
-                Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
-                args.FoundMatch() ? RS_(L"SearchBox_MatchesAvailable") : RS_(L"SearchBox_NoMatches"), // what to announce if results were found
-                L"SearchBoxResultAnnouncement" /* unique name for this group of notifications */);
-        }

-        _UpdateSearchScrollMarks();

         if (_searchBox)
         {
+            if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(*this) })
+            {
+                automationPeer.RaiseNotificationEvent(
+                    Automation::Peers::AutomationNotificationKind::ActionCompleted,
+                    Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
+                    args.FoundMatch() ? RS_(L"SearchBox_MatchesAvailable") : RS_(L"SearchBox_NoMatches"), // what to announce if results were found
+                    L"SearchBoxResultAnnouncement" /* unique name for this group of notifications */);
+            }
+
+            _UpdateSearchScrollMarks();
+
             _searchBox->NavigationEnabled(true);
             if (args.State() == Control::SearchState::Inactive)
             {

but I've got a consistent repro of the crash, so just lemme know

@zadjii-msft commented on GitHub (Apr 19, 2024): Mmk, lemme know when you've got a fix ready. My half assed fix was: ```diff diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index acab82931..1692a981a 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -3569,19 +3569,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation winrt::fire_and_forget TermControl::_coreUpdateSearchResults(const IInspectable& /*sender*/, Control::UpdateSearchResultsEventArgs args) { co_await wil::resume_foreground(Dispatcher()); - if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(*this) }) - { - automationPeer.RaiseNotificationEvent( - Automation::Peers::AutomationNotificationKind::ActionCompleted, - Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent, - args.FoundMatch() ? RS_(L"SearchBox_MatchesAvailable") : RS_(L"SearchBox_NoMatches"), // what to announce if results were found - L"SearchBoxResultAnnouncement" /* unique name for this group of notifications */); - } - _UpdateSearchScrollMarks(); if (_searchBox) { + if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(*this) }) + { + automationPeer.RaiseNotificationEvent( + Automation::Peers::AutomationNotificationKind::ActionCompleted, + Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent, + args.FoundMatch() ? RS_(L"SearchBox_MatchesAvailable") : RS_(L"SearchBox_NoMatches"), // what to announce if results were found + L"SearchBoxResultAnnouncement" /* unique name for this group of notifications */); + } + + _UpdateSearchScrollMarks(); + _searchBox->NavigationEnabled(true); if (args.State() == Control::SearchState::Inactive) { ``` but I've got a consistent repro of the crash, so just lemme know
Author
Owner

@AvogatoWizardWhisker commented on GitHub (Apr 22, 2024):

Crash also occurs when I close Terminal, however it hangs then crashes.

image

@AvogatoWizardWhisker commented on GitHub (Apr 22, 2024): Crash also occurs when I close Terminal, however it hangs then crashes. ![image](https://github.com/microsoft/terminal/assets/89489853/ee44c1a4-abf2-4a13-95a0-2b915a65de54)
Author
Owner

@zadjii-msft commented on GitHub (Apr 23, 2024):

@AvogatoWizardWhisker can you file a new issue for that hang/crash on shutdown? adding your settings & state.json will probably be helpful for debugging. I want to make sure that gets sorted separately before the 1.21 release ☺️

@zadjii-msft commented on GitHub (Apr 23, 2024): @AvogatoWizardWhisker can you file a new issue for that hang/crash on shutdown? adding your settings & state.json will probably be helpful for debugging. I want to make sure that gets sorted separately before the 1.21 release ☺️
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21554