Terminal crashing when last tab is closed with exit, 2021 edition #13577

Closed
opened 2026-01-31 03:46:18 +00:00 by claunia · 13 comments
Owner

Originally created by @hhromic on GitHub (Apr 21, 2021).

Originally assigned to: @lhecker on GitHub.

I'm getting constant crashes when closing the last tab. I analyzed a minidump from this crash (see below).

Due to restrictions in my corporation, I can only install Windows Terminal using the bundle file in the releases page of this repository: Microsoft.WindowsTerminal_1.7.1091.0_8wekyb3d8bbwe.msixbundle.

On my personal computer I use the Microsoft Store version of Windows Terminal which does NOT crash.

Let me know of anything you need to help debugging this issue 👍

Expand for stack trace.
0:000> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************


KEY_VALUES_STRING: 1

    Key  : Analysis.CPU.Sec
    Value: 11

    Key  : Analysis.DebugAnalysisProvider.CPP
    Value: Create: 8007007e on (redacted)

    Key  : Analysis.DebugData
    Value: CreateObject

    Key  : Analysis.DebugModel
    Value: CreateObject

    Key  : Analysis.Elapsed.Sec
    Value: 108

    Key  : Analysis.Memory.CommitPeak.Mb
    Value: 162

    Key  : Analysis.System
    Value: CreateObject

    Key  : Timeline.Process.Start.DeltaSec
    Value: 14


NTGLOBALFLAG:  0

PROCESS_BAM_CURRENT_THROTTLED: 0

PROCESS_BAM_PREVIOUS_THROTTLED: 0

APPLICATION_VERIFIER_FLAGS:  0

CONTEXT:  (.ecxr)
rax=0000008fcd4fc180 rbx=0000008fcd4fc0e0 rcx=0000008fcd4fc180
rdx=0000000000000000 rsi=0000000000000003 rdi=0000008fcd4fc180
rip=00007ffd08f80c0f rsp=0000008fcd4fc0a0 rbp=0000008fcd4fc770
 r8=0000000000000000  r9=0000000000000000 r10=0000026f85bd49c0
r11=5555555555555555 r12=0000000000000004 r13=0000008fcd4fca98
r14=0000000000000000 r15=0000008fcd4fd8e8
iopl=0         nv up ei pl zr na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000244
KERNELBASE!RaiseFailFastException+0xaf:
00007ffd`08f80c0f 0f1f440000      nop     dword ptr [rax+rax]
Resetting default scope

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 00007ffd0ab9940b (combase!RoFailFastWithErrorContextInternal2+0x000000000000050b)
   ExceptionCode: c0000602
  ExceptionFlags: 00000001
NumberParameters: 0

PROCESS_NAME:  WindowsTerminal.exe

ERROR_CODE: (NTSTATUS) 0xc0000602 - {Fail Fast Exception}  A fail fast exception occurred. Exception handlers will not be invoked and the process will be terminated immediately.

EXCEPTION_CODE_STR:  c0000602

STACK_TEXT:  
0000008f`cd4fc0a0 00007ffd`0ab9940b : 00000000`00000000 00000000`00000000 00000000`00000000 00007ffd`0ac943d0 : KERNELBASE!RaiseFailFastException+0xaf
0000008f`cd4fc670 00007ffc`b64a57df : 00007ffd`0ab99940 00007ffc`ff892519 0000008f`cd4fe370 0000008f`cd4febc0 : combase!RoFailFastWithErrorContextInternal2+0x50b
0000008f`cd4fc950 00007ffc`b648e739 : 00000000`8000ffff 00007ffd`01ab34af 00007ffc`b64ad79d 00007ffc`b6470000 : TerminalControl+0x357df
0000008f`cd4fc980 00007ffc`b6532319 : 00007ffc`ff8a5280 00007ffc`ff8a52a0 00007ffc`ff8a52b0 00007ffc`ff8a5280 : TerminalControl+0x1e739
0000008f`cd4fc9b0 00007ffd`01ab1080 : 00007ffc`b65322fa 0000008f`cd4fed90 0000008f`cd4fed90 00007ffc`ff8a5280 : TerminalControl!DllGetActivationFactory+0x82dd9
0000008f`cd4fc9e0 00007ffd`01ab26a5 : 00007ffc`b65322fa 0000008f`cd4fd8e8 0000026f`00000100 00000000`00000000 : VCRUNTIME140_1!_CallSettingFrame_LookupContinuationIndex+0x20
0000008f`cd4fca10 00007ffd`0be21336 : 00000000`00000000 00000000`00000003 00000000`00000000 0000008f`cd4febc0 : VCRUNTIME140_1!__FrameHandler4::CxxCallCatchBlock+0x115
0000008f`cd4fcaf0 00007ffc`b65247f9 : 0000026f`f6e51200 0000026f`8530a2e0 0000008f`cd4fee00 00000000`00000000 : ntdll!RcConsolidateFrames+0x6
0000008f`cd4fed90 00007ffc`b64a5531 : 0000026f`8530a2e0 0000026f`f6f9e590 0000026f`85bf73c0 00000000`00000018 : TerminalControl!DllGetActivationFactory+0x752b9
0000008f`cd4fee30 00007ffc`fb7afb51 : 0000026f`f6d60100 00000000`00000001 00000000`00000000 00000000`00000000 : TerminalControl+0x35531
0000008f`cd4fee60 00007ffd`029efbf6 : 0000026f`f6e00da0 0000026f`f6f9e590 0000026f`f6d60340 00000000`004000a0 : Windows_UI!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl Windows::System::IDispatcherQueueHandler::*)(void)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,Windows::System::IDispatcherQueueHandler,Microsoft::WRL::FtmBase>,<lambda_59517943c03487243f9bea31c6c1a784>,-1>::Invoke+0x71
0000008f`cd4fee90 00007ffd`029bbd46 : 0000026f`f6f078d0 0000026f`85bf73c0 0000026f`f6f078d0 0000026f`85bf73c0 : CoreMessaging!Windows::System::DispatcherQueue::DeferInvokeCallback+0x16
0000008f`cd4feec0 00007ffd`029bae8d : 00000000`00000000 0000026f`f6f07b20 0000026f`85bf73c0 0000026f`fa1377d0 : CoreMessaging!Microsoft__CoreUI__Dispatch__TimeoutHandler$CallbackThunk+0x186
0000008f`cd4fef40 00007ffd`029ba818 : 0000026f`fa1377d0 0000026f`fff644a0 0000026f`fa1377d0 00000000`00000003 : CoreMessaging!Microsoft::CoreUI::Dispatch::DeferredCall::Callback_Dispatch+0x2bd
0000008f`cd4feff0 00007ffd`029c1108 : 00000000`00000006 0000026f`f6e367c0 0000026f`f6e367c0 00000000`00000006 : CoreMessaging!Microsoft::CoreUI::Dispatch::DeferredCallDispatcher::Callback_OnDispatch+0x158
0000008f`cd4ff060 00007ffd`029c0491 : 0000026f`f6e52340 0000008f`cd4ff198 0000026f`f6f0c9b0 0000026f`f6e6a710 : CoreMessaging!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop+0xa68
0000008f`cd4ff140 00007ffd`029bfd99 : 0000026f`f6e6a710 0000026f`f6f13260 ffffffff`ffffffff 00007ffd`0a615aa4 : CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch+0x1d1
0000008f`cd4ff230 00007ffd`029bfbcb : 00000000`00000005 0000026f`f6f13260 00000000`00000000 00000000`40000c02 : CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter_DoWork+0xe9
0000008f`cd4ff310 00007ffd`0a615c1d : 00000000`00000002 00000000`80000022 00000000`00000001 0000008f`cd4ff750 : CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter_WindowProc+0x9b
0000008f`cd4ff340 00007ffd`0a615612 : 0000026f`f74f1f90 00007ffd`029bfb30 00000000`000f02f8 0000008f`cd4ff590 : user32!UserCallWinProcCheckWow+0x2bd
0000008f`cd4ff4d0 00007ffc`ff74150b : 00007ffd`029bfb30 0000026f`f6e26848 0000026f`f6e39f40 00007ffd`0bdc06fc : user32!DispatchMessageWorker+0x1e2
0000008f`cd4ff550 00007ffc`ff743979 : 00000000`000f02f8 0000008f`cd4ff6e8 00000000`00000000 00000000`00000000 : Microsoft_Toolkit_Win32_UI_XamlHost+0x150b
0000008f`cd4ff5e0 00007ff6`9d2e785c : 0000008f`cd4ff6e8 00000000`00000000 00000000`00000000 00000000`00000000 : Microsoft_Toolkit_Win32_UI_XamlHost+0x3979
0000008f`cd4ff610 00007ff6`9d2e57be : 00000000`00000000 00000000`00000005 00000000`00000000 00780065`002e006c : WindowsTerminal+0x785c
0000008f`cd4ff650 00007ff6`9d2f3e12 : 00000000`00000005 00000000`00000000 00000000`00000000 00000000`00000000 : WindowsTerminal+0x57be
0000008f`cd4ff800 00007ffd`0b217c24 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : WindowsTerminal+0x13e12
0000008f`cd4ff840 00007ffd`0bded721 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x14
0000008f`cd4ff870 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21


SYMBOL_NAME:  terminalcontrol+357df

MODULE_NAME: TerminalControl

IMAGE_NAME:  TerminalControl.dll

STACK_COMMAND:  ~0s ; .ecxr ; kb

FAILURE_BUCKET_ID:  FAIL_FAST_EXCEPTION_c0000602_TerminalControl.dll!Unknown

OS_VERSION:  10.0.18362.1

BUILDLAB_STR:  19h1_release

OSPLATFORM_TYPE:  x64

OSNAME:  Windows 10

FAILURE_ID_HASH:  {ac27ec0d-741f-9773-6afa-117b0a1e2a8d}

Followup:     MachineOwner
---------

0:000> lmvm TerminalControl
Browse full module list
start             end                 module name
00007ffc`b6470000 00007ffc`b656e000   TerminalControl   (export symbols)       TerminalControl.dll
    Loaded symbol image file: TerminalControl.dll
    Mapped memory image file: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.7.1091.0_x64__8wekyb3d8bbwe\TerminalControl.dll
    Image path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.7.1091.0_x64__8wekyb3d8bbwe\TerminalControl.dll
    Image name: TerminalControl.dll
    Browse all global symbols  functions  data
    Timestamp:        Mon Apr 19 22:25:11 2021 (607DF537)
    CheckSum:         000FB1D0
    ImageSize:        000FE000
    File version:     1.7.2104.19001
    Product version:  1.7.2104.19001
    File flags:       0 (Mask 3F)
    File OS:          4 Unknown Win32
    File type:        2.0 Dll
    File date:        00000000.00000000
    Translations:     0000.04b0
    Information from resource tables:

Originally created by @hhromic on GitHub (Apr 21, 2021). Originally assigned to: @lhecker on GitHub. I'm getting constant crashes when closing the last tab. I analyzed a minidump from this crash (see below). Due to restrictions in my corporation, I can only install Windows Terminal using the bundle file in the releases page of this repository: `Microsoft.WindowsTerminal_1.7.1091.0_8wekyb3d8bbwe.msixbundle`. On my personal computer I use the Microsoft Store version of Windows Terminal which does NOT crash. Let me know of anything you need to help debugging this issue 👍 <details> <summary>Expand for stack trace.</summary> ``` 0:000> !analyze -v ******************************************************************************* * * * Exception Analysis * * * ******************************************************************************* KEY_VALUES_STRING: 1 Key : Analysis.CPU.Sec Value: 11 Key : Analysis.DebugAnalysisProvider.CPP Value: Create: 8007007e on (redacted) Key : Analysis.DebugData Value: CreateObject Key : Analysis.DebugModel Value: CreateObject Key : Analysis.Elapsed.Sec Value: 108 Key : Analysis.Memory.CommitPeak.Mb Value: 162 Key : Analysis.System Value: CreateObject Key : Timeline.Process.Start.DeltaSec Value: 14 NTGLOBALFLAG: 0 PROCESS_BAM_CURRENT_THROTTLED: 0 PROCESS_BAM_PREVIOUS_THROTTLED: 0 APPLICATION_VERIFIER_FLAGS: 0 CONTEXT: (.ecxr) rax=0000008fcd4fc180 rbx=0000008fcd4fc0e0 rcx=0000008fcd4fc180 rdx=0000000000000000 rsi=0000000000000003 rdi=0000008fcd4fc180 rip=00007ffd08f80c0f rsp=0000008fcd4fc0a0 rbp=0000008fcd4fc770 r8=0000000000000000 r9=0000000000000000 r10=0000026f85bd49c0 r11=5555555555555555 r12=0000000000000004 r13=0000008fcd4fca98 r14=0000000000000000 r15=0000008fcd4fd8e8 iopl=0 nv up ei pl zr na po nc cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000244 KERNELBASE!RaiseFailFastException+0xaf: 00007ffd`08f80c0f 0f1f440000 nop dword ptr [rax+rax] Resetting default scope EXCEPTION_RECORD: (.exr -1) ExceptionAddress: 00007ffd0ab9940b (combase!RoFailFastWithErrorContextInternal2+0x000000000000050b) ExceptionCode: c0000602 ExceptionFlags: 00000001 NumberParameters: 0 PROCESS_NAME: WindowsTerminal.exe ERROR_CODE: (NTSTATUS) 0xc0000602 - {Fail Fast Exception} A fail fast exception occurred. Exception handlers will not be invoked and the process will be terminated immediately. EXCEPTION_CODE_STR: c0000602 STACK_TEXT: 0000008f`cd4fc0a0 00007ffd`0ab9940b : 00000000`00000000 00000000`00000000 00000000`00000000 00007ffd`0ac943d0 : KERNELBASE!RaiseFailFastException+0xaf 0000008f`cd4fc670 00007ffc`b64a57df : 00007ffd`0ab99940 00007ffc`ff892519 0000008f`cd4fe370 0000008f`cd4febc0 : combase!RoFailFastWithErrorContextInternal2+0x50b 0000008f`cd4fc950 00007ffc`b648e739 : 00000000`8000ffff 00007ffd`01ab34af 00007ffc`b64ad79d 00007ffc`b6470000 : TerminalControl+0x357df 0000008f`cd4fc980 00007ffc`b6532319 : 00007ffc`ff8a5280 00007ffc`ff8a52a0 00007ffc`ff8a52b0 00007ffc`ff8a5280 : TerminalControl+0x1e739 0000008f`cd4fc9b0 00007ffd`01ab1080 : 00007ffc`b65322fa 0000008f`cd4fed90 0000008f`cd4fed90 00007ffc`ff8a5280 : TerminalControl!DllGetActivationFactory+0x82dd9 0000008f`cd4fc9e0 00007ffd`01ab26a5 : 00007ffc`b65322fa 0000008f`cd4fd8e8 0000026f`00000100 00000000`00000000 : VCRUNTIME140_1!_CallSettingFrame_LookupContinuationIndex+0x20 0000008f`cd4fca10 00007ffd`0be21336 : 00000000`00000000 00000000`00000003 00000000`00000000 0000008f`cd4febc0 : VCRUNTIME140_1!__FrameHandler4::CxxCallCatchBlock+0x115 0000008f`cd4fcaf0 00007ffc`b65247f9 : 0000026f`f6e51200 0000026f`8530a2e0 0000008f`cd4fee00 00000000`00000000 : ntdll!RcConsolidateFrames+0x6 0000008f`cd4fed90 00007ffc`b64a5531 : 0000026f`8530a2e0 0000026f`f6f9e590 0000026f`85bf73c0 00000000`00000018 : TerminalControl!DllGetActivationFactory+0x752b9 0000008f`cd4fee30 00007ffc`fb7afb51 : 0000026f`f6d60100 00000000`00000001 00000000`00000000 00000000`00000000 : TerminalControl+0x35531 0000008f`cd4fee60 00007ffd`029efbf6 : 0000026f`f6e00da0 0000026f`f6f9e590 0000026f`f6d60340 00000000`004000a0 : Windows_UI!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl Windows::System::IDispatcherQueueHandler::*)(void)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,Windows::System::IDispatcherQueueHandler,Microsoft::WRL::FtmBase>,<lambda_59517943c03487243f9bea31c6c1a784>,-1>::Invoke+0x71 0000008f`cd4fee90 00007ffd`029bbd46 : 0000026f`f6f078d0 0000026f`85bf73c0 0000026f`f6f078d0 0000026f`85bf73c0 : CoreMessaging!Windows::System::DispatcherQueue::DeferInvokeCallback+0x16 0000008f`cd4feec0 00007ffd`029bae8d : 00000000`00000000 0000026f`f6f07b20 0000026f`85bf73c0 0000026f`fa1377d0 : CoreMessaging!Microsoft__CoreUI__Dispatch__TimeoutHandler$CallbackThunk+0x186 0000008f`cd4fef40 00007ffd`029ba818 : 0000026f`fa1377d0 0000026f`fff644a0 0000026f`fa1377d0 00000000`00000003 : CoreMessaging!Microsoft::CoreUI::Dispatch::DeferredCall::Callback_Dispatch+0x2bd 0000008f`cd4feff0 00007ffd`029c1108 : 00000000`00000006 0000026f`f6e367c0 0000026f`f6e367c0 00000000`00000006 : CoreMessaging!Microsoft::CoreUI::Dispatch::DeferredCallDispatcher::Callback_OnDispatch+0x158 0000008f`cd4ff060 00007ffd`029c0491 : 0000026f`f6e52340 0000008f`cd4ff198 0000026f`f6f0c9b0 0000026f`f6e6a710 : CoreMessaging!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop+0xa68 0000008f`cd4ff140 00007ffd`029bfd99 : 0000026f`f6e6a710 0000026f`f6f13260 ffffffff`ffffffff 00007ffd`0a615aa4 : CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch+0x1d1 0000008f`cd4ff230 00007ffd`029bfbcb : 00000000`00000005 0000026f`f6f13260 00000000`00000000 00000000`40000c02 : CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter_DoWork+0xe9 0000008f`cd4ff310 00007ffd`0a615c1d : 00000000`00000002 00000000`80000022 00000000`00000001 0000008f`cd4ff750 : CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter_WindowProc+0x9b 0000008f`cd4ff340 00007ffd`0a615612 : 0000026f`f74f1f90 00007ffd`029bfb30 00000000`000f02f8 0000008f`cd4ff590 : user32!UserCallWinProcCheckWow+0x2bd 0000008f`cd4ff4d0 00007ffc`ff74150b : 00007ffd`029bfb30 0000026f`f6e26848 0000026f`f6e39f40 00007ffd`0bdc06fc : user32!DispatchMessageWorker+0x1e2 0000008f`cd4ff550 00007ffc`ff743979 : 00000000`000f02f8 0000008f`cd4ff6e8 00000000`00000000 00000000`00000000 : Microsoft_Toolkit_Win32_UI_XamlHost+0x150b 0000008f`cd4ff5e0 00007ff6`9d2e785c : 0000008f`cd4ff6e8 00000000`00000000 00000000`00000000 00000000`00000000 : Microsoft_Toolkit_Win32_UI_XamlHost+0x3979 0000008f`cd4ff610 00007ff6`9d2e57be : 00000000`00000000 00000000`00000005 00000000`00000000 00780065`002e006c : WindowsTerminal+0x785c 0000008f`cd4ff650 00007ff6`9d2f3e12 : 00000000`00000005 00000000`00000000 00000000`00000000 00000000`00000000 : WindowsTerminal+0x57be 0000008f`cd4ff800 00007ffd`0b217c24 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : WindowsTerminal+0x13e12 0000008f`cd4ff840 00007ffd`0bded721 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x14 0000008f`cd4ff870 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21 SYMBOL_NAME: terminalcontrol+357df MODULE_NAME: TerminalControl IMAGE_NAME: TerminalControl.dll STACK_COMMAND: ~0s ; .ecxr ; kb FAILURE_BUCKET_ID: FAIL_FAST_EXCEPTION_c0000602_TerminalControl.dll!Unknown OS_VERSION: 10.0.18362.1 BUILDLAB_STR: 19h1_release OSPLATFORM_TYPE: x64 OSNAME: Windows 10 FAILURE_ID_HASH: {ac27ec0d-741f-9773-6afa-117b0a1e2a8d} Followup: MachineOwner --------- 0:000> lmvm TerminalControl Browse full module list start end module name 00007ffc`b6470000 00007ffc`b656e000 TerminalControl (export symbols) TerminalControl.dll Loaded symbol image file: TerminalControl.dll Mapped memory image file: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.7.1091.0_x64__8wekyb3d8bbwe\TerminalControl.dll Image path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.7.1091.0_x64__8wekyb3d8bbwe\TerminalControl.dll Image name: TerminalControl.dll Browse all global symbols functions data Timestamp: Mon Apr 19 22:25:11 2021 (607DF537) CheckSum: 000FB1D0 ImageSize: 000FE000 File version: 1.7.2104.19001 Product version: 1.7.2104.19001 File flags: 0 (Mask 3F) File OS: 4 Unknown Win32 File type: 2.0 Dll File date: 00000000.00000000 Translations: 0000.04b0 Information from resource tables: ``` </details>
Author
Owner

@zadjii-msft commented on GitHub (Apr 21, 2021):

Well that's weird. It really only crashes when the last tab is a WSL profile, not anything else? That's weird. Could you share your settings.json? Maybe there's something about your WSL profile that's special that's causing this.

@zadjii-msft commented on GitHub (Apr 21, 2021): Well that's weird. It really only crashes when the last tab is a WSL profile, not anything else? That's weird. Could you share your `settings.json`? Maybe there's something about your WSL profile that's special that's causing this.
Author
Owner

@hhromic commented on GitHub (Apr 21, 2021):

Hi @zadjii-msft , sorry I was a bit trigger-happy with the bug report. I did more extensive experiments now with a clearer head and I can confirm the following:

  • You are right, it does not happen only with WSL sessions. PowerShell and Cmd also suffer the same problem.
  • It is always the last tab to be closed (the one that closes the terminal window itself). If you open/close multiple tabs but there is always one open, there are no crashes.
  • Something I didn't notice before: If you start a new Terminal (no previous tabs open) and type exit quickly enough, then it does not crash. Same for PowerShell and Cmd when set as default. However, if just wait a moment before exiting the terminal, then it crashes. Therefore, there is a timing component involved in the crash.
  • Another thing I didn't notice: if you close the last tab with the close button (X) then it never crashes.

So in summary, it seems that when the shell process exits by itself (i.e. by typing exit or using Ctrl-D), then Windows Terminal crashes. If Windows Terminal initiates the shutdown (i.e. the X close button), then it is ok. Again, all of this only for the last tab in the window. You can happily exit shells in other tabs as long as there is one still open.

As for my settings.json file, I have not done any customisation than the defaults for these tests. It is rather big so let me know if you still would like to see it. Also let me know of anything else you would like me to test for futher debugging.

Thanks!

@hhromic commented on GitHub (Apr 21, 2021): Hi @zadjii-msft , sorry I was a bit trigger-happy with the bug report. I did more extensive experiments now with a clearer head and I can confirm the following: * You are right, it does not happen only with WSL sessions. PowerShell and Cmd also suffer the same problem. * It is always the last tab to be closed (the one that closes the terminal window itself). If you open/close multiple tabs but there is always one open, there are no crashes. * Something I didn't notice before: If you start a new Terminal (no previous tabs open) and type `exit` quickly enough, then it does not crash. Same for PowerShell and Cmd when set as default. However, if just wait a moment before exiting the terminal, then it crashes. Therefore, there is a timing component involved in the crash. * Another thing I didn't notice: if you close the last tab with the close button (`X`) then it never crashes. So in summary, it seems that when the shell process exits by itself (i.e. by typing `exit` or using Ctrl-D), then Windows Terminal crashes. If Windows Terminal initiates the shutdown (i.e. the `X` close button), then it is ok. Again, all of this only for the last tab in the window. You can happily exit shells in other tabs as long as there is one still open. As for my `settings.json` file, I have not done any customisation than the defaults for these tests. It is rather big so let me know if you still would like to see it. Also let me know of anything else you would like me to test for futher debugging. Thanks!
Author
Owner

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

You know what, I think I hit this yesterday too. Repro wasn't too hard, but yea exit is the important test bit here.

Stack was:

Expando for stack trace
0:000> k
 # Child-SP          RetAddr               Call Site
00 00000068`b49abaa0 00007ffc`c041e89f     KERNELBASE!RaiseFailFastException+0x152 [minkernel\kernelbase\xcpt.c @ 1198] 
01 00000068`b49ac080 00007ffc`169ebb50     combase!RoFailFastWithErrorContextInternal2+0x5af [onecore\com\combase\winrt\error\error.cpp @ 1481] 
02 00000068`b49ac2f0 00007ffc`16acd7df     Microsoft_Terminal_Control!winrt::terminate+0x70 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\Generated Files\winrt\base.h @ 5009] 
03 00000068`b49ac340 00007ffc`16d5160f     Microsoft_Terminal_Control!std::experimental::coroutine_traits<winrt::fire_and_forget,std::chrono::duration<__int64,std::ratio<1,10000000> >,winrt::Windows::UI::Core::CoreDispatcher,std::weak_ptr<ThrottledFunc<> > >::promise_type::unhandled_exception+0x2f [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\Generated Files\winrt\base.h @ 9059] 
04 00000068`b49ac370 00007ffc`bcd11080     Microsoft_Terminal_Control!`ThrottledFunc<>::_Fire$_ResumeCoro$1'::`1'::catch$2+0x4f [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\ThrottledFunc.h @ 166] 
05 00000068`b49ac3b0 00007ffc`bcd1399e     VCRUNTIME140_1D!_CallSettingFrame_LookupContinuationIndex+0x20 [D:\agent\_work\20\s\src\vctools\crt\vcruntime\src\eh\amd64\handlers.asm @ 98] 
06 00000068`b49ac3e0 00007ffc`c2365806     VCRUNTIME140_1D!__FrameHandler4::CxxCallCatchBlock+0x1de [D:\agent\_work\20\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 1367] 
07 00000068`b49ac4b0 00007ffc`16abb0c6     ntdll!RcFrameConsolidation+0x6 [minkernel\ntos\rtl\amd64\capture.asm @ 1124] 
08 00000068`b49aeb40 00007ffc`169e99e1     Microsoft_Terminal_Control!ThrottledFunc<>::_Fire$_ResumeCoro$1+0x876 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\ThrottledFunc.h @ 164] 
09 00000068`b49aefa0 00007ffc`169b74d4     Microsoft_Terminal_Control!std::experimental::coroutine_handle<void>::resume+0x61 [C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\experimental\coroutine @ 108] 
0a 00000068`b49aeff0 00007ffc`16aa1c17     Microsoft_Terminal_Control!std::experimental::coroutine_handle<void>::operator()+0x34 [C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\experimental\coroutine @ 100] 
0b 00000068`b49af020 00007ffc`16aacfac     Microsoft_Terminal_Control!<lambda_2ab9998b3c4eacdb9b89a7a0699bc21a>::operator()+0x37 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\Generated Files\winrt\windows.ui.core.h @ 2831] 
0c 00000068`b49af050 00007ffc`ac113818     Microsoft_Terminal_Control!winrt::impl::delegate<winrt::Windows::UI::Core::DispatchedHandler,<lambda_2ab9998b3c4eacdb9b89a7a0699bc21a> >::Invoke+0x3c [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\Generated Files\winrt\windows.ui.core.h @ 1088] 
0d 00000068`b49af090 00007ffc`ac0d37af     Windows_UI!<lambda_59517943c03487243f9bea31c6c1a784>::operator()+0x84 [onecoreuap\windows\advcore\winrt\onecoreiwindow\corewindow\common\dispatcher.cpp @ 908] 
0e 00000068`b49af0c0 00007ffc`bc32a440     Windows_UI!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl Windows::System::IDispatcherQueueHandler::*)(void)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,Windows::System::IDispatcherQueueHandler,Microsoft::WRL::FtmBase>,<lambda_59517943c03487243f9bea31c6c1a784>,-1>::Invoke+0xf [onecore\external\sdk\inc\wrl\event.h @ 354] 
0f 00000068`b49af0f0 00007ffc`bc30229c     CoreMessaging!Windows::System::DispatcherQueue::DeferInvokeCallback+0x20 [mincore\coreui\dev\dispatcherqueue\wrtdispatcherqueue.cpp @ 903] 
10 (Inline Function) --------`--------     CoreMessaging!Microsoft::CoreUI::ActionCallback::ImportAdapter$::__l2::<lambda_a81ff790741c2a62f2197c2561f5fe49>::operator()+0x1f [mincore\CoreUI\Dev\System\Api\IExportMessageSession.cs @ 22] 
11 00000068`b49af120 00007ffc`bc3021e1     CoreMessaging!CFlat::SehSafe::Execute<<lambda_a81ff790741c2a62f2197c2561f5fe49> >+0x2c [CFlatCorlib\1.0.201209001\CFlatCorlib\SehSafe.inl @ 11] 
12 00000068`b49af150 00007ffc`bc2e44cb     CoreMessaging!Microsoft::CoreUI::ActionCallback::ImportAdapter$+0xb1 [mincore\CoreUI\Dev\System\Api\IExportMessageSession.cs @ 22] 
13 (Inline Function) --------`--------     CoreMessaging!CFlat::DelegateImpl<Microsoft::CoreUI::ActionCallback,0,void __cdecl(void),long __cdecl(void *),0>::Invoke+0x26 [CFlatCorlib\1.0.201209001\CFlatCorlib\Delegate.h @ 334] 
14 00000068`b49af1a0 00007ffc`bc2e40af     CoreMessaging!Microsoft::CoreUI::Dispatch::DeferredCall::Callback_Dispatch+0x5b [mincore\CoreUI\Dev\System\Dispatch\DeferredCall.cs @ 62] 
15 00000068`b49af260 00007ffc`bc2e3d0d     CoreMessaging!Microsoft::CoreUI::Dispatch::DeferredCallDispatcher::Callback_OnDispatch+0x14f [mincore\CoreUI\Dev\System\Dispatch\DeferredCallDispatcher.cs @ 356] 
16 (Inline Function) --------`--------     CoreMessaging!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchNextItem+0x11b [mincore\CoreUI\Dev\System\Dispatch\Dispatcher.cs @ 936] 
17 (Inline Function) --------`--------     CoreMessaging!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchLoop+0x1df [mincore\CoreUI\Dev\System\Dispatch\Dispatcher.cs @ 478] 
18 00000068`b49af300 00007ffc`bc2e53c0     CoreMessaging!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop+0x2ed [mincore\CoreUI\Dev\System\Dispatch\EventLoop.cs @ 614] 
19 (Inline Function) --------`--------     CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::DrainCoreMessagingQueue+0x195 [mincore\CoreUI\Dev\System\Dispatch\UserAdapter.cs @ 745] 
1a 00000068`b49af3c0 00007ffc`bc2e5067     CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch+0x220 [mincore\CoreUI\Dev\System\Dispatch\UserAdapter.cs @ 1081] 
1b (Inline Function) --------`--------     CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatchRaw+0x69 [mincore\CoreUI\Dev\System\Dispatch\UserAdapter.cs @ 1006] 
1c 00000068`b49af450 00007ffc`bc2e4dc4     CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::DoWork+0x1f7 [mincore\coreui\dev\system\Dispatch\UserAdapterCommonN.cpp @ 198] 
1d 00000068`b49af4e0 00007ffc`c171a844     CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::WindowProc+0x84 [mincore\coreui\dev\system\Dispatch\UserAdapterCommonN.cpp @ 130] 
1e 00000068`b49af550 00007ffc`c171a46c     user32!UserCallWinProcCheckWow+0x364 [clientcore\windows\core\ntuser\client\clmsg.cxx @ 282] 
1f 00000068`b49af6b0 00007ffc`c1723a9d     user32!DispatchClientMessage+0x9c [clientcore\windows\core\ntuser\client\daytona\objfre\amd64\client.cxx @ 3435] 
20 00000068`b49af710 00007ffc`c2364f54     user32!__fnDWORD+0x3d [onecoreuap\restricted\windows\inc\ntuser\inc\ntcb.h @ 1214] 
21 00000068`b49af770 00007ffc`bfc813b4     ntdll!KiUserCallbackDispatcherContinue [minkernel\ntos\rtl\amd64\trampoln.asm @ 603] 
22 00000068`b49af7f8 00007ffc`c17221df     win32u!ZwUserPeekMessage+0x14 [onecoreuap\windows\core\umode\moderncore\objfre\amd64\usrstubs.asm @ 165] 
23 00000068`b49af800 00007ffc`c172212f     user32!_PeekMessage+0x3f [clientcore\windows\core\ntuser\client\ntstubs.cxx @ 930] 
24 00000068`b49af870 00007ffc`a61014f5     user32!PeekMessageW+0x10f [onecoreuap\restricted\windows\inc\private\core\ntuser\client\cltxt.h @ 768] 
25 00000068`b49af8e0 00007ffc`a6103979     Microsoft_Toolkit_Win32_UI_XamlHost+0x14f5
26 00000068`b49af970 00007ff7`c70a8455     Microsoft_Toolkit_Win32_UI_XamlHost+0x3979
27 00000068`b49af9a0 00007ff7`c70886cd     WindowsTerminal!winrt::impl::consume_Windows_Foundation_IClosable<winrt::TerminalApp::App>::Close+0x65 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\WindowsTerminal\Generated Files\winrt\Windows.Foundation.h @ 120] 
28 00000068`b49af9f0 00007ff7`c707f620     WindowsTerminal!AppHost::~AppHost+0x5d [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\WindowsTerminal\AppHost.cpp @ 84] 
29 00000068`b49afa30 00007ff7`c70d7e82     WindowsTerminal!wWinMain+0x280 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\WindowsTerminal\main.cpp @ 177] 
2a 00000068`b49afb90 00007ff7`c70d7dae     WindowsTerminal!invoke_main+0x32 [d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 123] 
2b 00000068`b49afbd0 00007ff7`c70d7c6e     WindowsTerminal!__scrt_common_main_seh+0x12e [d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 
2c 00000068`b49afc40 00007ff7`c70d7efe     WindowsTerminal!__scrt_common_main+0xe [d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 331] 
2d 00000068`b49afc70 00007ffc`c07c54e0     WindowsTerminal!wWinMainCRTStartup+0xe [d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_wwinmain.cpp @ 17] 
2e 00000068`b49afca0 00007ffc`c233b0bb     KERNEL32!BaseThreadInitThunk+0x10 [clientcore\base\win32\client\thread.c @ 75] 
2f 00000068`b49afcd0 00000000`00000000     ntdll!RtlUserThreadStart+0x2b [minkernel\ntdll\rtlstrt.c @ 1152] 



Unfortunately, nothing in the stack itself points at which ThrottledFunc was the murderer, but @DHowett's got a theory that it's the TSF one.

Probably related to #9729 (if I had to guess).

@zadjii-msft commented on GitHub (Apr 23, 2021): You know what, I think I hit this yesterday too. Repro wasn't too hard, but yea `exit` is the important test bit here. Stack was: <details> <summary>Expando for stack trace</summary> ``` 0:000> k # Child-SP RetAddr Call Site 00 00000068`b49abaa0 00007ffc`c041e89f KERNELBASE!RaiseFailFastException+0x152 [minkernel\kernelbase\xcpt.c @ 1198] 01 00000068`b49ac080 00007ffc`169ebb50 combase!RoFailFastWithErrorContextInternal2+0x5af [onecore\com\combase\winrt\error\error.cpp @ 1481] 02 00000068`b49ac2f0 00007ffc`16acd7df Microsoft_Terminal_Control!winrt::terminate+0x70 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\Generated Files\winrt\base.h @ 5009] 03 00000068`b49ac340 00007ffc`16d5160f Microsoft_Terminal_Control!std::experimental::coroutine_traits<winrt::fire_and_forget,std::chrono::duration<__int64,std::ratio<1,10000000> >,winrt::Windows::UI::Core::CoreDispatcher,std::weak_ptr<ThrottledFunc<> > >::promise_type::unhandled_exception+0x2f [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\Generated Files\winrt\base.h @ 9059] 04 00000068`b49ac370 00007ffc`bcd11080 Microsoft_Terminal_Control!`ThrottledFunc<>::_Fire$_ResumeCoro$1'::`1'::catch$2+0x4f [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\ThrottledFunc.h @ 166] 05 00000068`b49ac3b0 00007ffc`bcd1399e VCRUNTIME140_1D!_CallSettingFrame_LookupContinuationIndex+0x20 [D:\agent\_work\20\s\src\vctools\crt\vcruntime\src\eh\amd64\handlers.asm @ 98] 06 00000068`b49ac3e0 00007ffc`c2365806 VCRUNTIME140_1D!__FrameHandler4::CxxCallCatchBlock+0x1de [D:\agent\_work\20\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 1367] 07 00000068`b49ac4b0 00007ffc`16abb0c6 ntdll!RcFrameConsolidation+0x6 [minkernel\ntos\rtl\amd64\capture.asm @ 1124] 08 00000068`b49aeb40 00007ffc`169e99e1 Microsoft_Terminal_Control!ThrottledFunc<>::_Fire$_ResumeCoro$1+0x876 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\ThrottledFunc.h @ 164] 09 00000068`b49aefa0 00007ffc`169b74d4 Microsoft_Terminal_Control!std::experimental::coroutine_handle<void>::resume+0x61 [C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\experimental\coroutine @ 108] 0a 00000068`b49aeff0 00007ffc`16aa1c17 Microsoft_Terminal_Control!std::experimental::coroutine_handle<void>::operator()+0x34 [C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\experimental\coroutine @ 100] 0b 00000068`b49af020 00007ffc`16aacfac Microsoft_Terminal_Control!<lambda_2ab9998b3c4eacdb9b89a7a0699bc21a>::operator()+0x37 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\Generated Files\winrt\windows.ui.core.h @ 2831] 0c 00000068`b49af050 00007ffc`ac113818 Microsoft_Terminal_Control!winrt::impl::delegate<winrt::Windows::UI::Core::DispatchedHandler,<lambda_2ab9998b3c4eacdb9b89a7a0699bc21a> >::Invoke+0x3c [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\TerminalControl\Generated Files\winrt\windows.ui.core.h @ 1088] 0d 00000068`b49af090 00007ffc`ac0d37af Windows_UI!<lambda_59517943c03487243f9bea31c6c1a784>::operator()+0x84 [onecoreuap\windows\advcore\winrt\onecoreiwindow\corewindow\common\dispatcher.cpp @ 908] 0e 00000068`b49af0c0 00007ffc`bc32a440 Windows_UI!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl Windows::System::IDispatcherQueueHandler::*)(void)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,Windows::System::IDispatcherQueueHandler,Microsoft::WRL::FtmBase>,<lambda_59517943c03487243f9bea31c6c1a784>,-1>::Invoke+0xf [onecore\external\sdk\inc\wrl\event.h @ 354] 0f 00000068`b49af0f0 00007ffc`bc30229c CoreMessaging!Windows::System::DispatcherQueue::DeferInvokeCallback+0x20 [mincore\coreui\dev\dispatcherqueue\wrtdispatcherqueue.cpp @ 903] 10 (Inline Function) --------`-------- CoreMessaging!Microsoft::CoreUI::ActionCallback::ImportAdapter$::__l2::<lambda_a81ff790741c2a62f2197c2561f5fe49>::operator()+0x1f [mincore\CoreUI\Dev\System\Api\IExportMessageSession.cs @ 22] 11 00000068`b49af120 00007ffc`bc3021e1 CoreMessaging!CFlat::SehSafe::Execute<<lambda_a81ff790741c2a62f2197c2561f5fe49> >+0x2c [CFlatCorlib\1.0.201209001\CFlatCorlib\SehSafe.inl @ 11] 12 00000068`b49af150 00007ffc`bc2e44cb CoreMessaging!Microsoft::CoreUI::ActionCallback::ImportAdapter$+0xb1 [mincore\CoreUI\Dev\System\Api\IExportMessageSession.cs @ 22] 13 (Inline Function) --------`-------- CoreMessaging!CFlat::DelegateImpl<Microsoft::CoreUI::ActionCallback,0,void __cdecl(void),long __cdecl(void *),0>::Invoke+0x26 [CFlatCorlib\1.0.201209001\CFlatCorlib\Delegate.h @ 334] 14 00000068`b49af1a0 00007ffc`bc2e40af CoreMessaging!Microsoft::CoreUI::Dispatch::DeferredCall::Callback_Dispatch+0x5b [mincore\CoreUI\Dev\System\Dispatch\DeferredCall.cs @ 62] 15 00000068`b49af260 00007ffc`bc2e3d0d CoreMessaging!Microsoft::CoreUI::Dispatch::DeferredCallDispatcher::Callback_OnDispatch+0x14f [mincore\CoreUI\Dev\System\Dispatch\DeferredCallDispatcher.cs @ 356] 16 (Inline Function) --------`-------- CoreMessaging!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchNextItem+0x11b [mincore\CoreUI\Dev\System\Dispatch\Dispatcher.cs @ 936] 17 (Inline Function) --------`-------- CoreMessaging!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchLoop+0x1df [mincore\CoreUI\Dev\System\Dispatch\Dispatcher.cs @ 478] 18 00000068`b49af300 00007ffc`bc2e53c0 CoreMessaging!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop+0x2ed [mincore\CoreUI\Dev\System\Dispatch\EventLoop.cs @ 614] 19 (Inline Function) --------`-------- CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::DrainCoreMessagingQueue+0x195 [mincore\CoreUI\Dev\System\Dispatch\UserAdapter.cs @ 745] 1a 00000068`b49af3c0 00007ffc`bc2e5067 CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch+0x220 [mincore\CoreUI\Dev\System\Dispatch\UserAdapter.cs @ 1081] 1b (Inline Function) --------`-------- CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatchRaw+0x69 [mincore\CoreUI\Dev\System\Dispatch\UserAdapter.cs @ 1006] 1c 00000068`b49af450 00007ffc`bc2e4dc4 CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::DoWork+0x1f7 [mincore\coreui\dev\system\Dispatch\UserAdapterCommonN.cpp @ 198] 1d 00000068`b49af4e0 00007ffc`c171a844 CoreMessaging!Microsoft::CoreUI::Dispatch::UserAdapter::WindowProc+0x84 [mincore\coreui\dev\system\Dispatch\UserAdapterCommonN.cpp @ 130] 1e 00000068`b49af550 00007ffc`c171a46c user32!UserCallWinProcCheckWow+0x364 [clientcore\windows\core\ntuser\client\clmsg.cxx @ 282] 1f 00000068`b49af6b0 00007ffc`c1723a9d user32!DispatchClientMessage+0x9c [clientcore\windows\core\ntuser\client\daytona\objfre\amd64\client.cxx @ 3435] 20 00000068`b49af710 00007ffc`c2364f54 user32!__fnDWORD+0x3d [onecoreuap\restricted\windows\inc\ntuser\inc\ntcb.h @ 1214] 21 00000068`b49af770 00007ffc`bfc813b4 ntdll!KiUserCallbackDispatcherContinue [minkernel\ntos\rtl\amd64\trampoln.asm @ 603] 22 00000068`b49af7f8 00007ffc`c17221df win32u!ZwUserPeekMessage+0x14 [onecoreuap\windows\core\umode\moderncore\objfre\amd64\usrstubs.asm @ 165] 23 00000068`b49af800 00007ffc`c172212f user32!_PeekMessage+0x3f [clientcore\windows\core\ntuser\client\ntstubs.cxx @ 930] 24 00000068`b49af870 00007ffc`a61014f5 user32!PeekMessageW+0x10f [onecoreuap\restricted\windows\inc\private\core\ntuser\client\cltxt.h @ 768] 25 00000068`b49af8e0 00007ffc`a6103979 Microsoft_Toolkit_Win32_UI_XamlHost+0x14f5 26 00000068`b49af970 00007ff7`c70a8455 Microsoft_Toolkit_Win32_UI_XamlHost+0x3979 27 00000068`b49af9a0 00007ff7`c70886cd WindowsTerminal!winrt::impl::consume_Windows_Foundation_IClosable<winrt::TerminalApp::App>::Close+0x65 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\WindowsTerminal\Generated Files\winrt\Windows.Foundation.h @ 120] 28 00000068`b49af9f0 00007ff7`c707f620 WindowsTerminal!AppHost::~AppHost+0x5d [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\WindowsTerminal\AppHost.cpp @ 84] 29 00000068`b49afa30 00007ff7`c70d7e82 WindowsTerminal!wWinMain+0x280 [C:\Users\migrie\dev\private\OpenConsole\src\cascadia\WindowsTerminal\main.cpp @ 177] 2a 00000068`b49afb90 00007ff7`c70d7dae WindowsTerminal!invoke_main+0x32 [d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 123] 2b 00000068`b49afbd0 00007ff7`c70d7c6e WindowsTerminal!__scrt_common_main_seh+0x12e [d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 2c 00000068`b49afc40 00007ff7`c70d7efe WindowsTerminal!__scrt_common_main+0xe [d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 331] 2d 00000068`b49afc70 00007ffc`c07c54e0 WindowsTerminal!wWinMainCRTStartup+0xe [d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_wwinmain.cpp @ 17] 2e 00000068`b49afca0 00007ffc`c233b0bb KERNEL32!BaseThreadInitThunk+0x10 [clientcore\base\win32\client\thread.c @ 75] 2f 00000068`b49afcd0 00000000`00000000 ntdll!RtlUserThreadStart+0x2b [minkernel\ntdll\rtlstrt.c @ 1152] ``` </details> Unfortunately, nothing in the stack itself points at _which_ `ThrottledFunc` was the murderer, but @DHowett's got a theory that it's the TSF one. Probably related to #9729 (if I had to guess).
Author
Owner

@strngtn commented on GitHub (Apr 28, 2021):

Seem #9844 is a dup of this issue. I have the same issue same issue with Windows Terminal version 1.7.1033.0 on Windows 10 20H2.

After running exit in the last tab(no matter PS or winPS or CMD or WSL2), the window will crash instead of closing.

@strngtn commented on GitHub (Apr 28, 2021): Seem #9844 is a dup of this issue. I have the same issue same issue with Windows Terminal version 1.7.1033.0 on Windows 10 20H2. After running exit in the last tab(no matter PS or winPS or CMD or WSL2), the window will crash instead of closing.
Author
Owner

@j4james commented on GitHub (May 1, 2021):

To add another data point, I just got a crash on exit which I think looks different to others mentioned above. I was working on a branch of my own (based off of commit 2559ed6efa), so that may be a factor, but I don't think any of my changes would be relevant. In my case, the code path also passes through a ThrottledFunc callback, but the func in question appears to be ControlCore::UpdatePatternLocations.

Expand to view stack dump
>	ucrtbase.dll!00007ffb5711dace()	Unknown
 	vcruntime140.dll!00007ffb2e11699a()	Unknown
 	Microsoft.Terminal.Control.dll!Microsoft::Terminal::Core::Terminal::_InvalidateFromCoords(const _COORD start, const _COORD end) Line 743	C++
 	[Inline Frame] Microsoft.Terminal.Control.dll!Microsoft::Terminal::Core::Terminal::_InvalidatePatternTree::__l2::<lambda_9a52256f1328819638ef6d4b55293fb7>::operator()(const interval_tree::Interval<til::point,unsigned __int64> &) Line 708	C++
 	[Inline Frame] Microsoft.Terminal.Control.dll!std::for_each(std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<interval_tree::Interval<til::point,unsigned __int64>>>>) Line 299	C++
 	Microsoft.Terminal.Control.dll!interval_tree::IntervalTree<til::point,unsigned __int64>::visit_all<<lambda_9a52256f1328819638ef6d4b55293fb7>>(Microsoft::Terminal::Core::Terminal::_InvalidatePatternTree::__l2::<lambda_9a52256f1328819638ef6d4b55293fb7> f) Line 307	C++
 	[Inline Frame] Microsoft.Terminal.Control.dll!Microsoft::Terminal::Core::Terminal::_InvalidatePatternTree(interval_tree::IntervalTree<til::point,unsigned __int64> &) Line 710	C++
 	[Inline Frame] Microsoft.Terminal.Control.dll!Microsoft::Terminal::Core::Terminal::UpdatePatterns() Line 1210	C++
 	Microsoft.Terminal.Control.dll!winrt::Microsoft::Terminal::Control::implementation::ControlCore::UpdatePatternLocations() Line 416	C++
 	[External Code]	
 	[Inline Frame] Microsoft.Terminal.Control.dll!std::_Func_class<void>::operator()() Line 986	C++
 	Microsoft.Terminal.Control.dll!ThrottledFunc<>::_Fire$_ResumeCoro$1() Line 164	C++
 	[Inline Frame] Microsoft.Terminal.Control.dll!std::experimental::coroutine_handle<void>::resume() Line 107	C++
 	[Inline Frame] Microsoft.Terminal.Control.dll!std::experimental::coroutine_handle<void>::operator()() Line 99	C++
 	Microsoft.Terminal.Control.dll!winrt::impl::resume_apartment_callback(winrt::impl::com_callback_args * args) Line 1088	C++
 	[External Code]	
 	[Inline Frame] WindowsTerminal.exe!winrt::impl::consume_Windows_Foundation_IClosable<winrt::TerminalApp::App>::Close() Line 120	C++
 	WindowsTerminal.exe!AppHost::~AppHost() Line 95	C++
 	WindowsTerminal.exe!wWinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, wchar_t * __formal, int __formal) Line 177	C++
 	[External Code]	
@j4james commented on GitHub (May 1, 2021): To add another data point, I just got a crash on exit which I think looks different to others mentioned above. I was working on a branch of my own (based off of commit 2559ed6efa05cb8f999fbf0b8d890ec81161220a), so that may be a factor, but I don't think any of my changes would be relevant. In my case, the code path also passes through a `ThrottledFunc` callback, but the func in question appears to be `ControlCore::UpdatePatternLocations`. <details> <summary>Expand to view stack dump</summary> ``` > ucrtbase.dll!00007ffb5711dace() Unknown vcruntime140.dll!00007ffb2e11699a() Unknown Microsoft.Terminal.Control.dll!Microsoft::Terminal::Core::Terminal::_InvalidateFromCoords(const _COORD start, const _COORD end) Line 743 C++ [Inline Frame] Microsoft.Terminal.Control.dll!Microsoft::Terminal::Core::Terminal::_InvalidatePatternTree::__l2::<lambda_9a52256f1328819638ef6d4b55293fb7>::operator()(const interval_tree::Interval<til::point,unsigned __int64> &) Line 708 C++ [Inline Frame] Microsoft.Terminal.Control.dll!std::for_each(std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<interval_tree::Interval<til::point,unsigned __int64>>>>) Line 299 C++ Microsoft.Terminal.Control.dll!interval_tree::IntervalTree<til::point,unsigned __int64>::visit_all<<lambda_9a52256f1328819638ef6d4b55293fb7>>(Microsoft::Terminal::Core::Terminal::_InvalidatePatternTree::__l2::<lambda_9a52256f1328819638ef6d4b55293fb7> f) Line 307 C++ [Inline Frame] Microsoft.Terminal.Control.dll!Microsoft::Terminal::Core::Terminal::_InvalidatePatternTree(interval_tree::IntervalTree<til::point,unsigned __int64> &) Line 710 C++ [Inline Frame] Microsoft.Terminal.Control.dll!Microsoft::Terminal::Core::Terminal::UpdatePatterns() Line 1210 C++ Microsoft.Terminal.Control.dll!winrt::Microsoft::Terminal::Control::implementation::ControlCore::UpdatePatternLocations() Line 416 C++ [External Code] [Inline Frame] Microsoft.Terminal.Control.dll!std::_Func_class<void>::operator()() Line 986 C++ Microsoft.Terminal.Control.dll!ThrottledFunc<>::_Fire$_ResumeCoro$1() Line 164 C++ [Inline Frame] Microsoft.Terminal.Control.dll!std::experimental::coroutine_handle<void>::resume() Line 107 C++ [Inline Frame] Microsoft.Terminal.Control.dll!std::experimental::coroutine_handle<void>::operator()() Line 99 C++ Microsoft.Terminal.Control.dll!winrt::impl::resume_apartment_callback(winrt::impl::com_callback_args * args) Line 1088 C++ [External Code] [Inline Frame] WindowsTerminal.exe!winrt::impl::consume_Windows_Foundation_IClosable<winrt::TerminalApp::App>::Close() Line 120 C++ WindowsTerminal.exe!AppHost::~AppHost() Line 95 C++ WindowsTerminal.exe!wWinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, wchar_t * __formal, int __formal) Line 177 C++ [External Code] ``` </details>
Author
Owner

@Thomas1664 commented on GitHub (May 2, 2021):

Additional information:

Describe the bug
When I tried to close the app using command exit in PowerShell window, the application crashes. After debugging, it seems like there was the attempt to delete an already deleted pointer.
Steps To Reproduce

Steps to reproduce the behavior:
Open Tabs: PowerShell, Ubuntu (WSL)

  1. type exit in the Ubuntu Tab
  2. type exit in PowerShell
  3. See error

Expected behavior
Close without crash

Device and Application Information

  • OS Build: 19042.964
  • Architecture: x64
  • Application Version: 1.7.1033.0

Additional context

The crash is only reproducible if terminal is started with PS window and you open WSL Ubuntu manually. Then you have to terminate wsl using exit and PS using exit.

Stack trace (from Visual Studio debugger):
ucrtbase.dll!00007ffbb877286e()
vcruntime140.dll!00007ffba9f66bfa()
TerminalControl.dll!00007ffb7220dce2()
TerminalControl.dll!00007ffb7220f1f4()
TerminalControl.dll!00007ffb72188b3b()
TerminalControl.dll!00007ffb7219b0eb()
TerminalControl.dll!00007ffb722247f9()
TerminalControl.dll!00007ffb721a5531()
Windows.UI.dll!00007ffba13926a1()
CoreMessaging.dll!00007ffbb54b7406()
CoreMessaging.dll!00007ffbb54853db()
CoreMessaging.dll!00007ffbb5479c34()
CoreMessaging.dll!00007ffbb54794de()
CoreMessaging.dll!00007ffbb548996b()
CoreMessaging.dll!00007ffbb5488e26()
CoreMessaging.dll!00007ffbb5487061()
CoreMessaging.dll!00007ffbb5486e83()
user32.dll!00007ffbb90fe858()
user32.dll!00007ffbb90fe299()
Microsoft.Toolkit.Win32.UI.XamlHost.dll!00007ffba57c150b()
Microsoft.Toolkit.Win32.UI.XamlHost.dll!00007ffba57c3979()
WindowsTerminal.exe!00007ff6ccb6785c()
WindowsTerminal.exe!00007ff6ccb657be()
WindowsTerminal.exe!00007ff6ccb73e12()
kernel32.dll!00007ffbba0b7034()
ntdll.dll!00007ffbbad22651()

Exception details:
Ausnahmefehler bei 0x00007FFBB877286E (ucrtbase.dll) in WindowsTerminal.exe: Schwerwiegende Beendigung des Programms angefordert (Debugger points to memory address 0x0)

@Thomas1664 commented on GitHub (May 2, 2021): Additional information: **Describe the bug** When I tried to close the app using command `exit` in PowerShell window, the application crashes. After debugging, it seems like there was the attempt to delete an already deleted pointer. **Steps To Reproduce** Steps to reproduce the behavior: Open Tabs: PowerShell, Ubuntu (WSL) 1. type `exit` in the Ubuntu Tab 3. type `exit` in PowerShell 4. See error **Expected behavior** Close without crash **Device and Application Information** - OS Build: 19042.964 - Architecture: x64 - Application Version: 1.7.1033.0 **Additional context** <!-- Add any other context about the problem here. --> The crash is only reproducible if terminal is started with PS window and you open WSL Ubuntu manually. Then you have to terminate wsl using `exit` and PS using `exit`. Stack trace (from Visual Studio debugger): ucrtbase.dll!00007ffbb877286e() vcruntime140.dll!00007ffba9f66bfa() TerminalControl.dll!00007ffb7220dce2() TerminalControl.dll!00007ffb7220f1f4() TerminalControl.dll!00007ffb72188b3b() TerminalControl.dll!00007ffb7219b0eb() TerminalControl.dll!00007ffb722247f9() TerminalControl.dll!00007ffb721a5531() Windows.UI.dll!00007ffba13926a1() CoreMessaging.dll!00007ffbb54b7406() CoreMessaging.dll!00007ffbb54853db() CoreMessaging.dll!00007ffbb5479c34() CoreMessaging.dll!00007ffbb54794de() CoreMessaging.dll!00007ffbb548996b() CoreMessaging.dll!00007ffbb5488e26() CoreMessaging.dll!00007ffbb5487061() CoreMessaging.dll!00007ffbb5486e83() user32.dll!00007ffbb90fe858() user32.dll!00007ffbb90fe299() Microsoft.Toolkit.Win32.UI.XamlHost.dll!00007ffba57c150b() Microsoft.Toolkit.Win32.UI.XamlHost.dll!00007ffba57c3979() WindowsTerminal.exe!00007ff6ccb6785c() WindowsTerminal.exe!00007ff6ccb657be() WindowsTerminal.exe!00007ff6ccb73e12() kernel32.dll!00007ffbba0b7034() ntdll.dll!00007ffbbad22651() Exception details: Ausnahmefehler bei 0x00007FFBB877286E (ucrtbase.dll) in WindowsTerminal.exe: Schwerwiegende Beendigung des Programms angefordert (Debugger points to memory address 0x0)
Author
Owner

@lhecker commented on GitHub (May 4, 2021):

The crashes seen by @j4james and @Thomas1664 occur as the IRenderTarget / _renderer is allocated a std::unique_ptr (here), but is given to Terminal::CreateFromSettings by reference.
ControlCore::Close deallocates the _renderer, but it's entirely possible that ThrottledFuncs are still scheduled to call ControlCore::UpdatePatternLocations, which calls Terminal::UpdatePatterns, which in turn ends up accessing the deallocated IRenderTarget reference.

A proper solution with shared pointers is slightly harder than it appears initially and I've opted to not refactor this code for now. Instead I'll simply move the teardown and deallocation logic of the _renderer into ControlCore::~ControlCore.

@lhecker commented on GitHub (May 4, 2021): The crashes seen by @j4james and @Thomas1664 occur as the `IRenderTarget` / `_renderer` is allocated a `std::unique_ptr` ([here](https://github.com/microsoft/terminal/blob/2559ed6efa05cb8f999fbf0b8d890ec81161220a/src/cascadia/TerminalControl/ControlCore.cpp#L138)), but is given to `Terminal::CreateFromSettings` by reference. `ControlCore::Close` deallocates the `_renderer`, but it's entirely possible that `ThrottledFunc`s are still scheduled to call `ControlCore::UpdatePatternLocations`, which calls `Terminal::UpdatePatterns`, which in turn ends up accessing the deallocated `IRenderTarget` reference. A proper solution with shared pointers is slightly harder than it appears initially and I've opted to not refactor this code for now. Instead I'll simply move the teardown and deallocation logic of the `_renderer` into `ControlCore::~ControlCore`.
Author
Owner

@lhecker commented on GitHub (May 4, 2021):

Sorry for the unnecessary label changes, everyone!

I was unable to reproduce the originally reported crash stack trace, but I hope that my PR coincidentally fixes those crashes as well. As usual there should be a new version of Windows Terminal Preview available relatively soon. Please let me know if you still experience any such crashes then.

@lhecker commented on GitHub (May 4, 2021): Sorry for the unnecessary label changes, everyone! I was unable to reproduce the originally reported crash stack trace, but I hope that my PR coincidentally fixes those crashes as well. As usual there should be a new version of Windows Terminal Preview available relatively soon. Please let me know if you still experience any such crashes then.
Author
Owner

@hhromic commented on GitHub (May 4, 2021):

@lhecker thanks for working on this!
I'll be surely keeping an eye on the Preview version and report back if the crashes are solved after your PR. Cheers!

@hhromic commented on GitHub (May 4, 2021): @lhecker thanks for working on this! I'll be surely keeping an eye on the Preview version and report back if the crashes are solved after your PR. Cheers!
Author
Owner

@ghost commented on GitHub (May 25, 2021):

:tada:This issue was addressed in #10031, which has now been successfully released as Windows Terminal v1.8.1444.0.🎉

Handy links:

@ghost commented on GitHub (May 25, 2021): :tada:This issue was addressed in #10031, which has now been successfully released as `Windows Terminal v1.8.1444.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.8.1444.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ghost commented on GitHub (May 25, 2021):

:tada:This issue was addressed in #10031, which has now been successfully released as Windows Terminal Preview v1.9.1445.0.🎉

Handy links:

@ghost commented on GitHub (May 25, 2021): :tada:This issue was addressed in #10031, which has now been successfully released as `Windows Terminal Preview v1.9.1445.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.9.1445.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@hhromic commented on GitHub (May 26, 2021):

Hello everyone involved in fixing this bug.
I can fully confirm that the recent new stable version of Windows Terminal 1.8.1440.0 effectively fixes this crash for me! 🎉

Great work and I'm truly delighted on the commitment from the team to this application. Kudos!

@hhromic commented on GitHub (May 26, 2021): Hello everyone involved in fixing this bug. I can fully confirm that the recent new stable version of Windows Terminal `1.8.1440.0` effectively fixes this crash for me! 🎉 Great work and I'm truly delighted on the commitment from the team to this application. Kudos!
Author
Owner

@DHowett commented on GitHub (May 26, 2021):

Thanks for confirming!

@DHowett commented on GitHub (May 26, 2021): Thanks for confirming!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13577