winforms icon indicating copy to clipboard operation
winforms copied to clipboard

Deadlock with SystemEvents when application is shutdown

Open filipnavara opened this issue 3 years ago • 21 comments

This is very similar to dotnet/runtime#62042.

The process is being shut down. There's a window message processing thread for the system events (thread 6). Main thread (thread 0) is blocked on SystemEvents code hooked on the ProcessExit event. The SystemEvents.Shutdown code runs in the finalizer thread (thread 9) and waits for the message processing thread to die. The message processing thread is blocked on Invoke in SystemEvents.RaiseEvent that can never finish.

Dump here.

Parallel stacks: image

Shutdown thread:

Thread   0
TEB information is not available so a stack size of 0xFFFF is assumed
Current frame: win32u!NtUserMsgWaitForMultipleObjectsEx + 0xc
ChildEBP RetAddr  Caller, Callee
053BEF04 7691fcef user32!RealMsgWaitForMultipleObjectsEx + 0x8f, calling win32u!NtUserMsgWaitForMultipleObjectsEx
053BEF6C 774c0e6c combase!CCliModalLoop::PeekRPCAndDDEMessage + 0x31 [onecore\com\combase\dcomrem\callctrl.cxx:2607], calling combase!CCliModalLoop::MyPeekMessage [onecore\com\combase\dcomrem\callctrl.cxx:2918]
053BEF78 7691fbfd user32!MsgWaitForMultipleObjectsEx + 0x4d, calling user32!RealMsgWaitForMultipleObjectsEx
053BEF9C 7748adc8 combase!CCliModalLoop::BlockFn + 0x14b [onecore\com\combase\dcomrem\callctrl.cxx:2156], calling user32!MsgWaitForMultipleObjectsEx
053BF01C 7749b574 combase!ClassicSTAThreadWaitForHandles + 0xb4 [onecore\com\combase\dcomrem\classicsta.cpp:54], calling combase!CCliModalLoop::BlockFn [onecore\com\combase\dcomrem\callctrl.cxx:2036]
053BF0CC 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF0D8 7749a987 combase!CoWaitForMultipleHandles + 0x77 [onecore\com\combase\dcomrem\sync.cxx:122], calling combase!ClassicSTAThreadWaitForHandles [onecore\com\combase\dcomrem\classicsta.cpp:38]
053BF104 74ac4324 coreclr!MsgWaitHelper + 0x38 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3351], calling combase!CoWaitForMultipleHandles [onecore\com\combase\dcomrem\sync.cxx:86]
053BF128 74a37dee coreclr!Thread::DoAppropriateAptStateWait + 0x16b515 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3389], calling coreclr!MsgWaitHelper [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3315]
053BF140 748cc72d coreclr!Thread::DoAppropriateWaitWorker + 0x111 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3526], calling coreclr!Thread::DoAppropriateAptStateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3378]
053BF1D0 748cc5c8 coreclr!Thread::DoAppropriateWait + 0x76 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3243], calling coreclr!Thread::DoAppropriateWaitWorker [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3447]
053BF240 748cc2c7 coreclr!CLREventBase::WaitEx + 0x3c [D:\a\_work\1\s\src\coreclr\vm\synch.cpp:462], calling coreclr!Thread::DoAppropriateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3217]
053BF264 748cbf31 coreclr!CLREventBase::Wait + 0x1a [D:\a\_work\1\s\src\coreclr\vm\synch.cpp:413], calling coreclr!CLREventBase::WaitEx [D:\a\_work\1\s\src\coreclr\vm\synch.cpp:417]
053BF274 77763230 KERNELBASE!SetEvent + 0x10, calling ntdll_77890000!NtSetEvent
053BF27C 74992287 coreclr!FinalizerThread::RaiseShutdownEvents + 0x45 [D:\a\_work\1\s\src\coreclr\vm\finalizerthread.h:64], calling coreclr!CLREventBase::Wait [D:\a\_work\1\s\src\coreclr\vm\synch.cpp:410]
053BF28C 74991931 coreclr!EEShutDownHelper + 0x2aa [D:\a\_work\1\s\src\coreclr\vm\ceemain.cpp:1310], calling coreclr!FinalizerThread::RaiseShutdownEvents [D:\a\_work\1\s\src\coreclr\vm\finalizerthread.h:52]
053BF2D8 7496a9bd coreclr!`anonymous namespace'::GetConfigDWORD + 0x23 [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:240], calling coreclr!`anonymous namespace'::EnvGetString [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:139]
053BF2E4 7496aa18 coreclr!`anonymous namespace'::GetConfigDWORD + 0x7e [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:256], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF318 7496aa18 coreclr!`anonymous namespace'::GetConfigDWORD + 0x7e [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:256], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF31C 7496a984 coreclr!CLRConfig::GetConfigValue + 0x1c [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:434], calling coreclr!`anonymous namespace'::GetConfigDWORD [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:222]
053BF33C 749757e0 coreclr!CorHost2::ExecuteAssembly + 0x190 [D:\a\_work\1\s\src\coreclr\vm\corhost.cpp:400], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF380 749207b2 coreclr!CrstBase::Leave + 0xa [D:\a\_work\1\s\src\coreclr\vm\crst.cpp:358], calling ntdll_77890000!RtlLeaveCriticalSection
053BF3B0 74992417 coreclr!AppDomainIterator::Next + 0x55 [D:\a\_work\1\s\src\coreclr\vm\appdomain.hpp:2987], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF3B4 749923ba coreclr!MulticoreJitManager::StopProfileAll + 0x50 [D:\a\_work\1\s\src\coreclr\vm\multicorejit.cpp:1499], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF3E4 74991652 coreclr!EEShutDown + 0x66 [D:\a\_work\1\s\src\coreclr\vm\ceemain.cpp:1712], calling coreclr!EEShutDownHelper [D:\a\_work\1\s\src\coreclr\vm\ceemain.cpp:1215]
053BF414 74978206 coreclr!CorHost2::UnloadAppDomain2 + 0x36 [D:\a\_work\1\s\src\coreclr\vm\corhost.cpp:922], calling coreclr!EEShutDown [D:\a\_work\1\s\src\coreclr\vm\ceemain.cpp:1671]
053BF420 74978124 coreclr!coreclr_shutdown_2 + 0x54 [D:\a\_work\1\s\src\coreclr\dlls\mscoree\unixinterface.cpp:357]

Event processing thread:

Thread   9
TEB information is not available so a stack size of 0xFFFF is assumed
Current frame: ntdll_77890000!NtWaitForMultipleObjects + 0xc
ChildEBP RetAddr  Caller, Callee
1421F394 77761963 KERNELBASE!WaitForMultipleObjectsEx + 0x133, calling ntdll_77890000!NtWaitForMultipleObjects
1421F3BC 777619a1 KERNELBASE!WaitForMultipleObjectsEx + 0x171, calling KERNELBASE!__security_check_cookie
1421F3DC 777619b9 KERNELBASE!WaitForMultipleObjectsEx + 0x189, calling ntdll_77890000!RtlActivateActivationContextUnsafeFast
1421F440 778ee1a9 ntdll_77890000!RtlSetLastWin32Error + 0x39, calling ntdll_77890000!__security_check_cookie
1421F44C 77478b35 combase!CObjectContext::QIHelper + 0x175 [onecore\com\combase\dcomrem\context.cxx:1724]
1421F468 774789b5 combase!CObjectContext::QueryInterface + 0x15 [onecore\com\combase\dcomrem\context.cxx:1538], calling combase!CObjectContext::QIHelper [onecore\com\combase\dcomrem\context.cxx:1644]
1421F47C 749603eb coreclr!SafeQueryInterface + 0x65 [D:\a\_work\1\s\src\coreclr\vm\interoputil.cpp:1146]
1421F4BC 774cb578 combase!CObjectContext::GetCurrentThreadType + 0x18 [onecore\com\combase\dcomrem\context.cxx:4492], calling combase!IsApartmentInitialized [onecore\com\combase\class\compobj.cxx:4115]
1421F4D0 74960338 coreclr!GetCurrentThreadTypeNT5 + 0xf3 [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:132]
1421F4D4 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
1421F510 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
1421F528 748cc912 coreclr!Thread::DoAppropriateAptStateWait + 0x39 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3394], calling KERNELBASE!WaitForMultipleObjectsEx
1421F548 748cc72d coreclr!Thread::DoAppropriateWaitWorker + 0x111 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3526], calling coreclr!Thread::DoAppropriateAptStateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3378]
1421F5D8 748cc5c8 coreclr!Thread::DoAppropriateWait + 0x76 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3243], calling coreclr!Thread::DoAppropriateWaitWorker [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3447]
1421F648 748cc262 coreclr!WaitHandleNative::CorWaitOneNative + 0x52 [D:\a\_work\1\s\src\coreclr\vm\comwaithandle.cpp:31], calling coreclr!Thread::DoAppropriateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3217]
1421F6C0 748cc23f coreclr!WaitHandleNative::CorWaitOneNative + 0x2f [D:\a\_work\1\s\src\coreclr\vm\comwaithandle.cpp:24], calling coreclr!LazyMachStateCaptureState
1421F6E8 148f54b4 (MethodDesc 0d51f51c + 0x74 System.Threading.WaitHandle.WaitOneNoCheck(Int32)), calling 748cc210 (stub for System.Threading.WaitHandle.WaitOneCore(IntPtr, Int32))
1421F71C 148f568f (MethodDesc 0d51f510 + 0xf System.Threading.WaitHandle.WaitOne(Int32)), calling (MethodDesc 0d51f51c + 0 System.Threading.WaitHandle.WaitOneNoCheck(Int32))
1421F72C 148f566b (MethodDesc 0d51f5b4 + 0xb System.Threading.WaitHandle.WaitOne(Int32, Boolean))
1421F734 148f34a4 (MethodDesc 0d43a394 + 0x1a4 System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle))
1421F784 148f2f02 (MethodDesc 0d43b058 + 0x28a System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate, System.Object[], Boolean)), calling (MethodDesc 0d43a394 + 0 System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle))
1421F818 148f2b81 (MethodDesc 0d43aefc + 0x49 System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[])), calling 1490af50
1421F854 148f2a9f (MethodDesc 117f2f08 + 0xaf System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback, System.Object)), calling 1490af3c
1421F880 148f29a0 (MethodDesc 11b799b0 + 0x70 Microsoft.Win32.SystemEvents+SystemEventInvokeInfo.Invoke(Boolean, System.Object[]))
1421F8B4 148f272d (MethodDesc 11b79278 + 0xed Microsoft.Win32.SystemEvents.RaiseEvent(Boolean, System.Object, System.Object[])), calling 1490af00
1421F908 148f2625 (MethodDesc 11b79268 + 0x1d Microsoft.Win32.SystemEvents.RaiseEvent(System.Object, System.Object[])), calling (MethodDesc 11b79278 + 0 Microsoft.Win32.SystemEvents.RaiseEvent(Boolean, System.Object, System.Object[]))
1421F91C 148f28dd (MethodDesc 11b79238 + 0x8d Microsoft.Win32.SystemEvents.OnUserPreferenceChanged(Int32, IntPtr, IntPtr)), calling 1490ae9c
1421F93C 1180ece2 (MethodDesc 11b792b8 + 0x33a Microsoft.Win32.SystemEvents.WindowProc(IntPtr, Int32, IntPtr, IntPtr)), calling 1490aeb0
1421F954 76938cf3 user32!_InternalCallWinProc + 0x2b
1421F9C4 1180e979 (MethodDesc 11b7b60c + 0x41 ILStubClass.IL_STUB_ReversePInvoke(Int32, Int32, Int32, Int32))
1421F9EC 777649c0 KERNELBASE!GetProcessMitigationPolicy + 0xc0, calling ntdll_77890000!NtQueryInformationProcess
1421FA08 76938cf3 user32!_InternalCallWinProc + 0x2b
1421FA34 769193da user32!UserCallWinProcCheckWow + 0x4aa, calling user32!_InternalCallWinProc
1421FA78 769190b3 user32!UserCallWinProcCheckWow + 0x183, calling ntdll_77890000!RtlActivateActivationContextUnsafeFast
1421FA98 76920c56 user32!CallHookWithSEH + 0x2a
1421FB24 76917ee5 user32!DispatchMessageWorker + 0x4c5, calling user32!UserCallWinProcCheckWow
1421FB64 74941460 coreclr!NDirectImportWorker + 0x6b [D:\a\_work\1\s\src\coreclr\vm\dllimport.cpp:6081], calling ntdll_77890000!RtlSetLastWin32Error
1421FBA0 76917a10 user32!DispatchMessageW + 0x10, calling user32!DispatchMessageWorker
1421FBAC 1180dd0a (MethodDesc 11b792c8 + 0xea Microsoft.Win32.SystemEvents.WindowThreadProc()), calling user32!DispatchMessageW
1421FBC8 1180dd0a (MethodDesc 11b792c8 + 0xea Microsoft.Win32.SystemEvents.WindowThreadProc()), calling user32!DispatchMessageW
1421FC28 732d75f1 (MethodDesc 11b7a660 + 0x31 System.Threading.Thread+StartHelper.Callback(System.Object))
1421FC38 732dfb51 (MethodDesc 113f83d8 + 0x51 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
1421FC48 749cc1dd coreclr!ThePreStub + 0x11, calling coreclr!PreStubWorker [D:\a\_work\1\s\src\coreclr\vm\prestub.cpp:1955]
1421FC6C 732d65f2 (MethodDesc 0793f238 + 0x72 System.Threading.Thread.StartCallback()), calling System_Private_CoreLib + 0x44e9a8
1421FC80 749cbecf coreclr!CallDescrWorkerInternal + 0x34
1421FC8C 749149da coreclr!CallDescrWorkerWithHandler + 0x66 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:69], calling coreclr!CallDescrWorkerInternal
1421FCA0 749149a9 coreclr!CallDescrWorkerWithHandler + 0x35 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:65], calling coreclr!_chkstk [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\misc\i386\chkstk.asm:65]
1421FCC0 74932d7b coreclr!DispatchCallSimple + 0x7f [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:220], calling coreclr!CallDescrWorkerWithHandler [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:54]
1421FD08 749b6e8b coreclr!ThreadNative::KickOffThread_Worker + 0x4b [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:158], calling coreclr!DispatchCallSimple [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:173]
1421FD2C 74934e6f coreclr!ManagedThreadBase_DispatchMiddle + 0x8c [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7365]
1421FD70 748ca122 coreclr!Thread::HasStarted + 0x444 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:1986], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
1421FDB0 74934d9f coreclr!ManagedThreadBase_DispatchOuter + 0x62 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7543], calling coreclr!ManagedThreadBase_DispatchMiddle [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7325]
1421FDE8 748c9ade coreclr!ThreadNative::KickOffThread + 0x4e [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:207], calling coreclr!EventPipeHelper::IsEnabled [D:\a\_work\1\s\src\coreclr\vm\eventtrace.cpp:7862]
1421FE08 748c9b0f coreclr!ThreadNative::KickOffThread + 0x7f [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:230], calling coreclr!ManagedThreadBase_DispatchOuter [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7476]
1421FE3C 76816709 kernel32!BaseThreadInitThunk + 0x19
1421FE4C 778f7d1d ntdll_77890000!__RtlUserThreadStart + 0x2b
1421FEA4 778f7ceb ntdll_77890000!_RtlUserThreadStart + 0x1b, calling ntdll_77890000!__RtlUserThreadStart

Finalizer thread:

Thread   6
TEB information is not available so a stack size of 0xFFFF is assumed
Current frame: ntdll_77890000!NtWaitForMultipleObjects + 0xc
ChildEBP RetAddr  Caller, Callee
0ADAF8C4 77761963 KERNELBASE!WaitForMultipleObjectsEx + 0x133, calling ntdll_77890000!NtWaitForMultipleObjects
0ADAF90C 777619b9 KERNELBASE!WaitForMultipleObjectsEx + 0x189, calling ntdll_77890000!RtlActivateActivationContextUnsafeFast
0ADAF93C 7490f1f4 coreclr!MemberLoader::GetMethodDescFromMethodDef + 0x48 [D:\a\_work\1\s\src\coreclr\vm\memberload.cpp:640], calling coreclr!MethodDesc::CheckRestore [D:\a\_work\1\s\src\coreclr\vm\method.cpp:3953]
0ADAF944 7490f080 coreclr!MethodDesc::EnsureActive + 0x4a [D:\a\_work\1\s\src\coreclr\vm\method.cpp:209], calling coreclr!DomainFile::EnsureLoadLevel [D:\a\_work\1\s\src\coreclr\vm\domainfile.cpp:112]
0ADAF950 778ee1a9 ntdll_77890000!RtlSetLastWin32Error + 0x39, calling ntdll_77890000!__security_check_cookie
0ADAF95C 74910b85 coreclr!TransitionFrame::GetReturnAddressPtr + 0x15 [D:\a\_work\1\s\src\coreclr\vm\frames.h:943]
0ADAF970 749102a4 coreclr!ExternalMethodFixupWorker + 0x4c4 [D:\a\_work\1\s\src\coreclr\vm\prestub.cpp:2814], calling ntdll_77890000!RtlSetLastWin32Error
0ADAF97C 77478b35 combase!CObjectContext::QIHelper + 0x175 [onecore\com\combase\dcomrem\context.cxx:1724]
0ADAF998 774789b5 combase!CObjectContext::QueryInterface + 0x15 [onecore\com\combase\dcomrem\context.cxx:1538], calling combase!CObjectContext::QIHelper [onecore\com\combase\dcomrem\context.cxx:1644]
0ADAF9AC 749603eb coreclr!SafeQueryInterface + 0x65 [D:\a\_work\1\s\src\coreclr\vm\interoputil.cpp:1146]
0ADAF9EC 774cb578 combase!CObjectContext::GetCurrentThreadType + 0x18 [onecore\com\combase\dcomrem\context.cxx:4492], calling combase!IsApartmentInitialized [onecore\com\combase\class\compobj.cxx:4115]
0ADAFA00 74960338 coreclr!GetCurrentThreadTypeNT5 + 0xf3 [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:132]
0ADAFA04 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
0ADAFA40 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
0ADAFA58 748cc912 coreclr!Thread::DoAppropriateAptStateWait + 0x39 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3394], calling KERNELBASE!WaitForMultipleObjectsEx
0ADAFA78 748cc72d coreclr!Thread::DoAppropriateWaitWorker + 0x111 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3526], calling coreclr!Thread::DoAppropriateAptStateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3378]
0ADAFB08 748cc5c8 coreclr!Thread::DoAppropriateWait + 0x76 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3243], calling coreclr!Thread::DoAppropriateWaitWorker [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3447]
0ADAFB78 749b1858 coreclr!Thread::JoinEx + 0x53 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:447], calling coreclr!Thread::DoAppropriateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3217]
0ADAFBA4 749b170d coreclr!ThreadNative::DoJoin + 0xbd [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:889], calling coreclr!Thread::JoinEx [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:419]
0ADAFBE4 749b1624 coreclr!ThreadNative::Join + 0x64 [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:454], calling coreclr!ThreadNative::DoJoin [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:835]
0ADAFC44 749b15f5 coreclr!ThreadNative::Join + 0x35 [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:445], calling coreclr!LazyMachStateCaptureState
0ADAFC50 749cc1dd coreclr!ThePreStub + 0x11, calling coreclr!PreStubWorker [D:\a\_work\1\s\src\coreclr\vm\prestub.cpp:1955]
0ADAFC74 732d72db (MethodDesc 0793f88c + 0xb System.Threading.Thread.Join()), calling System_Private_CoreLib + 0x44e9a8
0ADAFC78 148f5220 (MethodDesc 11b79298 + 0xa0 Microsoft.Win32.SystemEvents.Shutdown()), calling 1490b1d0
0ADAFCA4 148f5169 (MethodDesc 11b792a8 + 0x11 Microsoft.Win32.SystemEvents.Shutdown(System.Object, System.EventArgs)), calling 1490b1bc
0ADAFCB4 0570d228 0570d228
0ADAFCE4 732122b5 (MethodDesc 07940258 + 0x55 System.AppContext.OnProcessExit())
0ADAFCF8 749cbecf coreclr!CallDescrWorkerInternal + 0x34
0ADAFD04 749149da coreclr!CallDescrWorkerWithHandler + 0x66 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:69], calling coreclr!CallDescrWorkerInternal
0ADAFD18 749149a9 coreclr!CallDescrWorkerWithHandler + 0x35 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:65], calling coreclr!_chkstk [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\misc\i386\chkstk.asm:65]
0ADAFD38 74915bba coreclr!MethodDescCallSite::CallTargetWorker + 0xe7 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:551], calling coreclr!CallDescrWorkerWithHandler [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:54]
0ADAFD3C 74916477 coreclr!ArgIteratorTemplate<ArgIteratorBase>::ComputeReturnFlags + 0x1b [D:\a\_work\1\s\src\coreclr\vm\callingconvention.h:1549], calling coreclr!MetaSig::GetReturnTypeNormalized [D:\a\_work\1\s\src\coreclr\vm\siginfo.cpp:5204]
0ADAFD58 74915b21 coreclr!MethodDescCallSite::CallTargetWorker + 0x4e [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:384], calling coreclr!_alloca_probe_16 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\misc\i386\alloca16.asm:44]
0ADAFD90 74936e1b coreclr!MethodDescCallSite::MethodDescCallSite + 0x3e [D:\a\_work\1\s\src\coreclr\vm\callhelpers.h:174], calling coreclr!MethodDesc::GetCallTarget [D:\a\_work\1\s\src\coreclr\vm\method.cpp:2206]
0ADAFD98 74936e26 coreclr!MethodDescCallSite::MethodDescCallSite + 0x49 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.h:175], calling coreclr!ArgIteratorTemplate<ArgIteratorBase>::ForceSigWalk [D:\a\_work\1\s\src\coreclr\vm\callingconvention.h:1652]
0ADAFDAC 749bf1b6 coreclr!AppDomain::RaiseExitProcessEvent + 0x2d [D:\a\_work\1\s\src\coreclr\vm\appdomain.cpp:4294], calling coreclr!MethodDescCallSite::CallTargetWorker [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:262]
0ADAFE3C 749bf155 coreclr!FinalizerThread::FinalizerThreadStart + 0x65 [D:\a\_work\1\s\src\coreclr\vm\finalizerthread.cpp:401], calling coreclr!AppDomain::RaiseExitProcessEvent [D:\a\_work\1\s\src\coreclr\vm\appdomain.cpp:4279]

filipnavara avatar Nov 15 '22 14:11 filipnavara

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost avatar Nov 15 '22 14:11 ghost

It's .NET 6 process but the Microsoft.Win32.SystemEvents library has the previous deadlock fix (7.0.0-preview.2.22076.14+5f72148e033b887ede8436fcdefdbec6cda83190).

filipnavara avatar Nov 15 '22 14:11 filipnavara

Tagging subscribers to this area: @dotnet/area-microsoft-win32 See info in area-owners.md if you want to be subscribed.

Issue Details

This is very similar to dotnet/runtime#62042.

The process is being shut down. There's a window message processing thread for the system events (thread 6). Main thread (thread 0) is blocked on SystemEvents code hooked on the ProcessExit event. The SystemEvents.Shutdown code runs in the finalizer thread (thread 9) and waits for the message processing thread to die. The message processing thread is blocked on Invoke in SystemEvents.RaiseEvent that can never finish.

Dump here.

Parallel stacks: image

Shutdown thread:

Thread   0
TEB information is not available so a stack size of 0xFFFF is assumed
Current frame: win32u!NtUserMsgWaitForMultipleObjectsEx + 0xc
ChildEBP RetAddr  Caller, Callee
053BEF04 7691fcef user32!RealMsgWaitForMultipleObjectsEx + 0x8f, calling win32u!NtUserMsgWaitForMultipleObjectsEx
053BEF6C 774c0e6c combase!CCliModalLoop::PeekRPCAndDDEMessage + 0x31 [onecore\com\combase\dcomrem\callctrl.cxx:2607], calling combase!CCliModalLoop::MyPeekMessage [onecore\com\combase\dcomrem\callctrl.cxx:2918]
053BEF78 7691fbfd user32!MsgWaitForMultipleObjectsEx + 0x4d, calling user32!RealMsgWaitForMultipleObjectsEx
053BEF9C 7748adc8 combase!CCliModalLoop::BlockFn + 0x14b [onecore\com\combase\dcomrem\callctrl.cxx:2156], calling user32!MsgWaitForMultipleObjectsEx
053BF01C 7749b574 combase!ClassicSTAThreadWaitForHandles + 0xb4 [onecore\com\combase\dcomrem\classicsta.cpp:54], calling combase!CCliModalLoop::BlockFn [onecore\com\combase\dcomrem\callctrl.cxx:2036]
053BF0CC 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF0D8 7749a987 combase!CoWaitForMultipleHandles + 0x77 [onecore\com\combase\dcomrem\sync.cxx:122], calling combase!ClassicSTAThreadWaitForHandles [onecore\com\combase\dcomrem\classicsta.cpp:38]
053BF104 74ac4324 coreclr!MsgWaitHelper + 0x38 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3351], calling combase!CoWaitForMultipleHandles [onecore\com\combase\dcomrem\sync.cxx:86]
053BF128 74a37dee coreclr!Thread::DoAppropriateAptStateWait + 0x16b515 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3389], calling coreclr!MsgWaitHelper [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3315]
053BF140 748cc72d coreclr!Thread::DoAppropriateWaitWorker + 0x111 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3526], calling coreclr!Thread::DoAppropriateAptStateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3378]
053BF1D0 748cc5c8 coreclr!Thread::DoAppropriateWait + 0x76 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3243], calling coreclr!Thread::DoAppropriateWaitWorker [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3447]
053BF240 748cc2c7 coreclr!CLREventBase::WaitEx + 0x3c [D:\a\_work\1\s\src\coreclr\vm\synch.cpp:462], calling coreclr!Thread::DoAppropriateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3217]
053BF264 748cbf31 coreclr!CLREventBase::Wait + 0x1a [D:\a\_work\1\s\src\coreclr\vm\synch.cpp:413], calling coreclr!CLREventBase::WaitEx [D:\a\_work\1\s\src\coreclr\vm\synch.cpp:417]
053BF274 77763230 KERNELBASE!SetEvent + 0x10, calling ntdll_77890000!NtSetEvent
053BF27C 74992287 coreclr!FinalizerThread::RaiseShutdownEvents + 0x45 [D:\a\_work\1\s\src\coreclr\vm\finalizerthread.h:64], calling coreclr!CLREventBase::Wait [D:\a\_work\1\s\src\coreclr\vm\synch.cpp:410]
053BF28C 74991931 coreclr!EEShutDownHelper + 0x2aa [D:\a\_work\1\s\src\coreclr\vm\ceemain.cpp:1310], calling coreclr!FinalizerThread::RaiseShutdownEvents [D:\a\_work\1\s\src\coreclr\vm\finalizerthread.h:52]
053BF2D8 7496a9bd coreclr!`anonymous namespace'::GetConfigDWORD + 0x23 [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:240], calling coreclr!`anonymous namespace'::EnvGetString [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:139]
053BF2E4 7496aa18 coreclr!`anonymous namespace'::GetConfigDWORD + 0x7e [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:256], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF318 7496aa18 coreclr!`anonymous namespace'::GetConfigDWORD + 0x7e [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:256], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF31C 7496a984 coreclr!CLRConfig::GetConfigValue + 0x1c [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:434], calling coreclr!`anonymous namespace'::GetConfigDWORD [D:\a\_work\1\s\src\coreclr\utilcode\clrconfig.cpp:222]
053BF33C 749757e0 coreclr!CorHost2::ExecuteAssembly + 0x190 [D:\a\_work\1\s\src\coreclr\vm\corhost.cpp:400], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF380 749207b2 coreclr!CrstBase::Leave + 0xa [D:\a\_work\1\s\src\coreclr\vm\crst.cpp:358], calling ntdll_77890000!RtlLeaveCriticalSection
053BF3B0 74992417 coreclr!AppDomainIterator::Next + 0x55 [D:\a\_work\1\s\src\coreclr\vm\appdomain.hpp:2987], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF3B4 749923ba coreclr!MulticoreJitManager::StopProfileAll + 0x50 [D:\a\_work\1\s\src\coreclr\vm\multicorejit.cpp:1499], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
053BF3E4 74991652 coreclr!EEShutDown + 0x66 [D:\a\_work\1\s\src\coreclr\vm\ceemain.cpp:1712], calling coreclr!EEShutDownHelper [D:\a\_work\1\s\src\coreclr\vm\ceemain.cpp:1215]
053BF414 74978206 coreclr!CorHost2::UnloadAppDomain2 + 0x36 [D:\a\_work\1\s\src\coreclr\vm\corhost.cpp:922], calling coreclr!EEShutDown [D:\a\_work\1\s\src\coreclr\vm\ceemain.cpp:1671]
053BF420 74978124 coreclr!coreclr_shutdown_2 + 0x54 [D:\a\_work\1\s\src\coreclr\dlls\mscoree\unixinterface.cpp:357]

Event processing thread:

Thread   9
TEB information is not available so a stack size of 0xFFFF is assumed
Current frame: ntdll_77890000!NtWaitForMultipleObjects + 0xc
ChildEBP RetAddr  Caller, Callee
1421F394 77761963 KERNELBASE!WaitForMultipleObjectsEx + 0x133, calling ntdll_77890000!NtWaitForMultipleObjects
1421F3BC 777619a1 KERNELBASE!WaitForMultipleObjectsEx + 0x171, calling KERNELBASE!__security_check_cookie
1421F3DC 777619b9 KERNELBASE!WaitForMultipleObjectsEx + 0x189, calling ntdll_77890000!RtlActivateActivationContextUnsafeFast
1421F440 778ee1a9 ntdll_77890000!RtlSetLastWin32Error + 0x39, calling ntdll_77890000!__security_check_cookie
1421F44C 77478b35 combase!CObjectContext::QIHelper + 0x175 [onecore\com\combase\dcomrem\context.cxx:1724]
1421F468 774789b5 combase!CObjectContext::QueryInterface + 0x15 [onecore\com\combase\dcomrem\context.cxx:1538], calling combase!CObjectContext::QIHelper [onecore\com\combase\dcomrem\context.cxx:1644]
1421F47C 749603eb coreclr!SafeQueryInterface + 0x65 [D:\a\_work\1\s\src\coreclr\vm\interoputil.cpp:1146]
1421F4BC 774cb578 combase!CObjectContext::GetCurrentThreadType + 0x18 [onecore\com\combase\dcomrem\context.cxx:4492], calling combase!IsApartmentInitialized [onecore\com\combase\class\compobj.cxx:4115]
1421F4D0 74960338 coreclr!GetCurrentThreadTypeNT5 + 0xf3 [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:132]
1421F4D4 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
1421F510 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
1421F528 748cc912 coreclr!Thread::DoAppropriateAptStateWait + 0x39 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3394], calling KERNELBASE!WaitForMultipleObjectsEx
1421F548 748cc72d coreclr!Thread::DoAppropriateWaitWorker + 0x111 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3526], calling coreclr!Thread::DoAppropriateAptStateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3378]
1421F5D8 748cc5c8 coreclr!Thread::DoAppropriateWait + 0x76 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3243], calling coreclr!Thread::DoAppropriateWaitWorker [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3447]
1421F648 748cc262 coreclr!WaitHandleNative::CorWaitOneNative + 0x52 [D:\a\_work\1\s\src\coreclr\vm\comwaithandle.cpp:31], calling coreclr!Thread::DoAppropriateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3217]
1421F6C0 748cc23f coreclr!WaitHandleNative::CorWaitOneNative + 0x2f [D:\a\_work\1\s\src\coreclr\vm\comwaithandle.cpp:24], calling coreclr!LazyMachStateCaptureState
1421F6E8 148f54b4 (MethodDesc 0d51f51c + 0x74 System.Threading.WaitHandle.WaitOneNoCheck(Int32)), calling 748cc210 (stub for System.Threading.WaitHandle.WaitOneCore(IntPtr, Int32))
1421F71C 148f568f (MethodDesc 0d51f510 + 0xf System.Threading.WaitHandle.WaitOne(Int32)), calling (MethodDesc 0d51f51c + 0 System.Threading.WaitHandle.WaitOneNoCheck(Int32))
1421F72C 148f566b (MethodDesc 0d51f5b4 + 0xb System.Threading.WaitHandle.WaitOne(Int32, Boolean))
1421F734 148f34a4 (MethodDesc 0d43a394 + 0x1a4 System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle))
1421F784 148f2f02 (MethodDesc 0d43b058 + 0x28a System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate, System.Object[], Boolean)), calling (MethodDesc 0d43a394 + 0 System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle))
1421F818 148f2b81 (MethodDesc 0d43aefc + 0x49 System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[])), calling 1490af50
1421F854 148f2a9f (MethodDesc 117f2f08 + 0xaf System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback, System.Object)), calling 1490af3c
1421F880 148f29a0 (MethodDesc 11b799b0 + 0x70 Microsoft.Win32.SystemEvents+SystemEventInvokeInfo.Invoke(Boolean, System.Object[]))
1421F8B4 148f272d (MethodDesc 11b79278 + 0xed Microsoft.Win32.SystemEvents.RaiseEvent(Boolean, System.Object, System.Object[])), calling 1490af00
1421F908 148f2625 (MethodDesc 11b79268 + 0x1d Microsoft.Win32.SystemEvents.RaiseEvent(System.Object, System.Object[])), calling (MethodDesc 11b79278 + 0 Microsoft.Win32.SystemEvents.RaiseEvent(Boolean, System.Object, System.Object[]))
1421F91C 148f28dd (MethodDesc 11b79238 + 0x8d Microsoft.Win32.SystemEvents.OnUserPreferenceChanged(Int32, IntPtr, IntPtr)), calling 1490ae9c
1421F93C 1180ece2 (MethodDesc 11b792b8 + 0x33a Microsoft.Win32.SystemEvents.WindowProc(IntPtr, Int32, IntPtr, IntPtr)), calling 1490aeb0
1421F954 76938cf3 user32!_InternalCallWinProc + 0x2b
1421F9C4 1180e979 (MethodDesc 11b7b60c + 0x41 ILStubClass.IL_STUB_ReversePInvoke(Int32, Int32, Int32, Int32))
1421F9EC 777649c0 KERNELBASE!GetProcessMitigationPolicy + 0xc0, calling ntdll_77890000!NtQueryInformationProcess
1421FA08 76938cf3 user32!_InternalCallWinProc + 0x2b
1421FA34 769193da user32!UserCallWinProcCheckWow + 0x4aa, calling user32!_InternalCallWinProc
1421FA78 769190b3 user32!UserCallWinProcCheckWow + 0x183, calling ntdll_77890000!RtlActivateActivationContextUnsafeFast
1421FA98 76920c56 user32!CallHookWithSEH + 0x2a
1421FB24 76917ee5 user32!DispatchMessageWorker + 0x4c5, calling user32!UserCallWinProcCheckWow
1421FB64 74941460 coreclr!NDirectImportWorker + 0x6b [D:\a\_work\1\s\src\coreclr\vm\dllimport.cpp:6081], calling ntdll_77890000!RtlSetLastWin32Error
1421FBA0 76917a10 user32!DispatchMessageW + 0x10, calling user32!DispatchMessageWorker
1421FBAC 1180dd0a (MethodDesc 11b792c8 + 0xea Microsoft.Win32.SystemEvents.WindowThreadProc()), calling user32!DispatchMessageW
1421FBC8 1180dd0a (MethodDesc 11b792c8 + 0xea Microsoft.Win32.SystemEvents.WindowThreadProc()), calling user32!DispatchMessageW
1421FC28 732d75f1 (MethodDesc 11b7a660 + 0x31 System.Threading.Thread+StartHelper.Callback(System.Object))
1421FC38 732dfb51 (MethodDesc 113f83d8 + 0x51 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
1421FC48 749cc1dd coreclr!ThePreStub + 0x11, calling coreclr!PreStubWorker [D:\a\_work\1\s\src\coreclr\vm\prestub.cpp:1955]
1421FC6C 732d65f2 (MethodDesc 0793f238 + 0x72 System.Threading.Thread.StartCallback()), calling System_Private_CoreLib + 0x44e9a8
1421FC80 749cbecf coreclr!CallDescrWorkerInternal + 0x34
1421FC8C 749149da coreclr!CallDescrWorkerWithHandler + 0x66 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:69], calling coreclr!CallDescrWorkerInternal
1421FCA0 749149a9 coreclr!CallDescrWorkerWithHandler + 0x35 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:65], calling coreclr!_chkstk [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\misc\i386\chkstk.asm:65]
1421FCC0 74932d7b coreclr!DispatchCallSimple + 0x7f [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:220], calling coreclr!CallDescrWorkerWithHandler [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:54]
1421FD08 749b6e8b coreclr!ThreadNative::KickOffThread_Worker + 0x4b [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:158], calling coreclr!DispatchCallSimple [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:173]
1421FD2C 74934e6f coreclr!ManagedThreadBase_DispatchMiddle + 0x8c [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7365]
1421FD70 748ca122 coreclr!Thread::HasStarted + 0x444 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:1986], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
1421FDB0 74934d9f coreclr!ManagedThreadBase_DispatchOuter + 0x62 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7543], calling coreclr!ManagedThreadBase_DispatchMiddle [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7325]
1421FDE8 748c9ade coreclr!ThreadNative::KickOffThread + 0x4e [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:207], calling coreclr!EventPipeHelper::IsEnabled [D:\a\_work\1\s\src\coreclr\vm\eventtrace.cpp:7862]
1421FE08 748c9b0f coreclr!ThreadNative::KickOffThread + 0x7f [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:230], calling coreclr!ManagedThreadBase_DispatchOuter [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7476]
1421FE3C 76816709 kernel32!BaseThreadInitThunk + 0x19
1421FE4C 778f7d1d ntdll_77890000!__RtlUserThreadStart + 0x2b
1421FEA4 778f7ceb ntdll_77890000!_RtlUserThreadStart + 0x1b, calling ntdll_77890000!__RtlUserThreadStart

Finalizer thread:

Thread   6
TEB information is not available so a stack size of 0xFFFF is assumed
Current frame: ntdll_77890000!NtWaitForMultipleObjects + 0xc
ChildEBP RetAddr  Caller, Callee
0ADAF8C4 77761963 KERNELBASE!WaitForMultipleObjectsEx + 0x133, calling ntdll_77890000!NtWaitForMultipleObjects
0ADAF90C 777619b9 KERNELBASE!WaitForMultipleObjectsEx + 0x189, calling ntdll_77890000!RtlActivateActivationContextUnsafeFast
0ADAF93C 7490f1f4 coreclr!MemberLoader::GetMethodDescFromMethodDef + 0x48 [D:\a\_work\1\s\src\coreclr\vm\memberload.cpp:640], calling coreclr!MethodDesc::CheckRestore [D:\a\_work\1\s\src\coreclr\vm\method.cpp:3953]
0ADAF944 7490f080 coreclr!MethodDesc::EnsureActive + 0x4a [D:\a\_work\1\s\src\coreclr\vm\method.cpp:209], calling coreclr!DomainFile::EnsureLoadLevel [D:\a\_work\1\s\src\coreclr\vm\domainfile.cpp:112]
0ADAF950 778ee1a9 ntdll_77890000!RtlSetLastWin32Error + 0x39, calling ntdll_77890000!__security_check_cookie
0ADAF95C 74910b85 coreclr!TransitionFrame::GetReturnAddressPtr + 0x15 [D:\a\_work\1\s\src\coreclr\vm\frames.h:943]
0ADAF970 749102a4 coreclr!ExternalMethodFixupWorker + 0x4c4 [D:\a\_work\1\s\src\coreclr\vm\prestub.cpp:2814], calling ntdll_77890000!RtlSetLastWin32Error
0ADAF97C 77478b35 combase!CObjectContext::QIHelper + 0x175 [onecore\com\combase\dcomrem\context.cxx:1724]
0ADAF998 774789b5 combase!CObjectContext::QueryInterface + 0x15 [onecore\com\combase\dcomrem\context.cxx:1538], calling combase!CObjectContext::QIHelper [onecore\com\combase\dcomrem\context.cxx:1644]
0ADAF9AC 749603eb coreclr!SafeQueryInterface + 0x65 [D:\a\_work\1\s\src\coreclr\vm\interoputil.cpp:1146]
0ADAF9EC 774cb578 combase!CObjectContext::GetCurrentThreadType + 0x18 [onecore\com\combase\dcomrem\context.cxx:4492], calling combase!IsApartmentInitialized [onecore\com\combase\class\compobj.cxx:4115]
0ADAFA00 74960338 coreclr!GetCurrentThreadTypeNT5 + 0xf3 [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:132]
0ADAFA04 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
0ADAFA40 74960362 coreclr!GetCurrentThreadTypeNT5 + 0x11d [D:\a\_work\1\s\src\coreclr\vm\olecontexthelpers.cpp:134], calling coreclr!_EH_epilog3 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\eh\i386\ehprolg3.c:529]
0ADAFA58 748cc912 coreclr!Thread::DoAppropriateAptStateWait + 0x39 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3394], calling KERNELBASE!WaitForMultipleObjectsEx
0ADAFA78 748cc72d coreclr!Thread::DoAppropriateWaitWorker + 0x111 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3526], calling coreclr!Thread::DoAppropriateAptStateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3378]
0ADAFB08 748cc5c8 coreclr!Thread::DoAppropriateWait + 0x76 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3243], calling coreclr!Thread::DoAppropriateWaitWorker [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3447]
0ADAFB78 749b1858 coreclr!Thread::JoinEx + 0x53 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:447], calling coreclr!Thread::DoAppropriateWait [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:3217]
0ADAFBA4 749b170d coreclr!ThreadNative::DoJoin + 0xbd [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:889], calling coreclr!Thread::JoinEx [D:\a\_work\1\s\src\coreclr\vm\threads.cpp:419]
0ADAFBE4 749b1624 coreclr!ThreadNative::Join + 0x64 [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:454], calling coreclr!ThreadNative::DoJoin [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:835]
0ADAFC44 749b15f5 coreclr!ThreadNative::Join + 0x35 [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp:445], calling coreclr!LazyMachStateCaptureState
0ADAFC50 749cc1dd coreclr!ThePreStub + 0x11, calling coreclr!PreStubWorker [D:\a\_work\1\s\src\coreclr\vm\prestub.cpp:1955]
0ADAFC74 732d72db (MethodDesc 0793f88c + 0xb System.Threading.Thread.Join()), calling System_Private_CoreLib + 0x44e9a8
0ADAFC78 148f5220 (MethodDesc 11b79298 + 0xa0 Microsoft.Win32.SystemEvents.Shutdown()), calling 1490b1d0
0ADAFCA4 148f5169 (MethodDesc 11b792a8 + 0x11 Microsoft.Win32.SystemEvents.Shutdown(System.Object, System.EventArgs)), calling 1490b1bc
0ADAFCB4 0570d228 0570d228
0ADAFCE4 732122b5 (MethodDesc 07940258 + 0x55 System.AppContext.OnProcessExit())
0ADAFCF8 749cbecf coreclr!CallDescrWorkerInternal + 0x34
0ADAFD04 749149da coreclr!CallDescrWorkerWithHandler + 0x66 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:69], calling coreclr!CallDescrWorkerInternal
0ADAFD18 749149a9 coreclr!CallDescrWorkerWithHandler + 0x35 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:65], calling coreclr!_chkstk [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\misc\i386\chkstk.asm:65]
0ADAFD38 74915bba coreclr!MethodDescCallSite::CallTargetWorker + 0xe7 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:551], calling coreclr!CallDescrWorkerWithHandler [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:54]
0ADAFD3C 74916477 coreclr!ArgIteratorTemplate<ArgIteratorBase>::ComputeReturnFlags + 0x1b [D:\a\_work\1\s\src\coreclr\vm\callingconvention.h:1549], calling coreclr!MetaSig::GetReturnTypeNormalized [D:\a\_work\1\s\src\coreclr\vm\siginfo.cpp:5204]
0ADAFD58 74915b21 coreclr!MethodDescCallSite::CallTargetWorker + 0x4e [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:384], calling coreclr!_alloca_probe_16 [d:\a01\_work\11\s\src\vctools\crt\vcstartup\src\misc\i386\alloca16.asm:44]
0ADAFD90 74936e1b coreclr!MethodDescCallSite::MethodDescCallSite + 0x3e [D:\a\_work\1\s\src\coreclr\vm\callhelpers.h:174], calling coreclr!MethodDesc::GetCallTarget [D:\a\_work\1\s\src\coreclr\vm\method.cpp:2206]
0ADAFD98 74936e26 coreclr!MethodDescCallSite::MethodDescCallSite + 0x49 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.h:175], calling coreclr!ArgIteratorTemplate<ArgIteratorBase>::ForceSigWalk [D:\a\_work\1\s\src\coreclr\vm\callingconvention.h:1652]
0ADAFDAC 749bf1b6 coreclr!AppDomain::RaiseExitProcessEvent + 0x2d [D:\a\_work\1\s\src\coreclr\vm\appdomain.cpp:4294], calling coreclr!MethodDescCallSite::CallTargetWorker [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp:262]
0ADAFE3C 749bf155 coreclr!FinalizerThread::FinalizerThreadStart + 0x65 [D:\a\_work\1\s\src\coreclr\vm\finalizerthread.cpp:401], calling coreclr!AppDomain::RaiseExitProcessEvent [D:\a\_work\1\s\src\coreclr\vm\appdomain.cpp:4279]
Author: filipnavara
Assignees: -
Labels:

bug, area-Microsoft.Win32, untriaged

Milestone: -

ghost avatar Nov 15 '22 14:11 ghost

Artifical repro: Hanger.zip

filipnavara avatar Aug 30 '23 07:08 filipnavara

@filipnavara did you have a chance to look at this to see if there's a fix you'd propose?

The repro you shared looks like it would just be a SendMessage call hanging - which I would expect to be the case if you send messages to a window that's not pumping messages.

In the case you described - the only thing I could imagine would be the ProcessExit handler to just signal the message thread to shutdown instead of wait on it. This seems like it might let that event handler thread continue to run after the process was shutting down which doesn't seem like a good idea.

You said:

The message processing thread is blocked on Invoke in SystemEvents.RaiseEvent that can never finish.

I don't think I understand why that can never finish.

1421F72C 148f566b (MethodDesc 0d51f5b4 + 0xb System.Threading.WaitHandle.WaitOne(Int32, Boolean))
1421F734 148f34a4 (MethodDesc 0d43a394 + 0x1a4 System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle))
1421F784 148f2f02 (MethodDesc 0d43b058 + 0x28a System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate, System.Object[], Boolean)), calling (MethodDesc 0d43a394 + 0 System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle))
1421F818 148f2b81 (MethodDesc 0d43aefc + 0x49 System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[])), calling 1490af50
1421F854 148f2a9f (MethodDesc 117f2f08 + 0xaf System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback, System.Object)), calling 1490af3c
1421F880 148f29a0 (MethodDesc 11b799b0 + 0x70 Microsoft.Win32.SystemEvents+SystemEventInvokeInfo.Invoke(Boolean, System.Object[]))

Shouldn't this WindowsFormsSynchronizationContext still have a UI thread running that it can invoke the handler on? Or did that get shutdown before unregistering a SystemEvent handler? cc @JeremyKuhne

ericstj avatar Sep 09 '23 01:09 ericstj

did you have a chance to look at this to see if there's a fix you'd propose?

Not really. I don't fully understand why SystemEventInvokeInfo.Invoke uses Send on the synchronization context. I would have expected Post to be sufficient since it still guarantees ordering but doesn't block the event processing thread. If there is a requirement to block the thread, it would still make sense to change to Post but with additional logic that waits both for the Post to finish or the shutdown to be signalled (the crucial missing part).

the only thing I could imagine would be the ProcessExit handler to just signal the message thread to shutdown instead of wait on it.

That may work but I am not sure what would be the consequences.

Shouldn't this WindowsFormsSynchronizationContext still have a UI thread running that it can invoke the handler on? Or did that get shutdown before unregistering a SystemEvent handler?

The UI thread is the one where the application shutdown was initialized. It's now deep inside the CoreCLR shutdown sequence and definitely not pumping messages.

There are two possible scenarios here:

  • The message loop on main thread never existed to start with. That's the trick in the simple repro above. You simply shut down the app before reaching Application.Run, which can happen for numerous reasons (eg. you bail out on early app logic initialization error, show message box, and try to exit).
  • The message loop on main thread existed but it's now effectively gone since the process is shutting down. The SynchronizationContext.Send call still waits for the message to be processed but that can never happen.

filipnavara avatar Sep 09 '23 05:09 filipnavara

Could it be related to this? https://github.com/dotnet/winforms/pull/9861? We just fixed for 7, but probably should fix on 6 as well. @lonitra

JeremyKuhne avatar Sep 11 '23 17:09 JeremyKuhne

Could it be related to this? dotnet/winforms#9861?

No. This problem is specific to the implementation of SystemEvents. The only thing in WinForms that's related is how WindowsFormsSynchronizationContext behaves during application shut down when there are outstanding Send requests on it.

filipnavara avatar Sep 11 '23 17:09 filipnavara

It is WindowsFormsSynchronizationContext that's deciding to push work to a blocked thread. It's unusual to me that WinForms isn't on the stack at all on the main thread. Is that normal?

I see that if the WindowsFormsSynchronizationContext was disposed it would actually noop here.
https://github.com/dotnet/winforms/blob/478c4e1d28e9adf29938c135aedbb31be47289fd/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSynchronizationContext.cs#L64-L88

@filipnavara can you see if any of the controls in the dump are disposed? Who's normally responsible for disposing controls in a WinForms app?

ericstj avatar Sep 11 '23 21:09 ericstj

can you see if any of the controls in the dump are disposed? Who's normally responsible for disposing controls in a WinForms app?

Unfortunately I am now away from my machine until September 19th and cannot check the dump.

There are certainly cases in WinForms where you don't explicitly dispose the Form and it happens as part of the window closing lifetime (for non-modal windows). Likewise, there is a hidden window used specifically for marshalling the messages from SynchronizationContext back to the main thread. Lifetime of this window is managed by WinForms themselves.

filipnavara avatar Sep 11 '23 21:09 filipnavara

It's unusual to me that WinForms isn't on the stack at all on the main thread. Is that normal?

I assume it is, the managed thread is dead. The whole runtime is already inside the shutdown sequence and SystemEvents happen to have a hook into that sequence (at ProcessExit).

filipnavara avatar Sep 11 '23 21:09 filipnavara

I'd like to better understand what's expected from the Winforms side of things here. @JeremyKuhne shouldn't WindowsFormsSynchronizationContext be able to know when it's waiting on work that will never get done?

ericstj avatar Sep 25 '23 16:09 ericstj

I met with @JeremyKuhne and @lonitra and they feel that it's possible that this is being caused by the same root cause as https://github.com/dotnet/winforms/pull/9861. That bug would have made it such that WindowsFormsSynchronizationContext believed it still had a non-disposed control that could handle messages, when in fact it did not.

We'd really like to see if you can reproduce this after that Winforms fix is in. Can you see if you can get any new repro of this with that fix?

ericstj avatar Sep 26 '23 21:09 ericstj

~~I am really quite sure it's unrelated to https://github.com/dotnet/winforms/pull/9861, or more specifically, that the instances I observed are unrelated. In fact, the repro above still shows that the problem exists in .NET 8 and .NET 9 nightly builds.~~

Okay, I re-read the history of that PR and bug, and I see why they believe it fixed the issue. There are multiple conditions that could lead to the WindowsFormsSynchronizationContext hang, and it's possible that the fixed one is the one that affected our customers. I cannot easily prove or disprove that.

That said, the repro I posted above hits a different condition (the main event loop not even starting).

filipnavara avatar Sep 26 '23 21:09 filipnavara

I'll try to send a build of our app with newer runtime/WinForms build to see if they still observe the error or not. Unfortunately it's not guaranteed that I will get any feedback.

filipnavara avatar Sep 26 '23 21:09 filipnavara

@filipnavara are you still hitting this? We haven't seen other reports.

ericstj avatar Aug 06 '24 18:08 ericstj

@filipnavara are you still hitting this? We haven't seen other reports.

I haven't had a report from our customers in quite a while. That said, I also didn't try to re-run the artificial repro from https://github.com/dotnet/winforms/issues/11944 to see if that still triggers an error. We should do that before closing the issue for good.

filipnavara avatar Aug 06 '24 18:08 filipnavara

I see. I ran your repro on the latest 9.0 bits and it does indeed still hang.

Here's the hang:

00 00000022`971ff188 00007ffc`9e23f65b     0x00007ffd`80fe7ef0
01 00000022`971ff190 00007ffc`9e24621e     System_Windows_Forms!System.Windows.Forms.Control.WaitForWaitHandle+0x9b [/_/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs @ 3776] 
02 00000022`971ff220 00007ffc`9e245508     System_Windows_Forms!System.Windows.Forms.Control.MarshaledInvoke+0x25e [/_/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs @ 6793] 
03 00000022`971ff2c0 00007ffc`9e4c49c3     System_Windows_Forms!System.Windows.Forms.Control.Invoke+0x48 [/_/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs @ 6278] 
04 00000022`971ff320 00007ffe`40f36ee5     System_Windows_Forms!System.Windows.Forms.WindowsFormsSynchronizationContext.Send+0x73 [/_/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSynchronizationContext.cs @ 87] 
05 00000022`971ff370 00007ffe`40f359e1     Microsoft_Win32_SystemEvents!Microsoft.Win32.SystemEvents.SystemEventInvokeInfo.Invoke+0x65 [/_/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs @ 1317] 
06 00000022`971ff3c0 00007ffe`40f35fd6     Microsoft_Win32_SystemEvents!Microsoft.Win32.SystemEvents.RaiseEvent+0x101 [/_/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs @ 1026] 
07 00000022`971ff450 00007ffd`80fe7ffc     Microsoft_Win32_SystemEvents!Microsoft.Win32.SystemEvents.WindowProc+0x1f6 [/_/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs @ 1170] 
00 00000022`96eff0e8 00007ffe`7acf65f9     ntdll!NtWaitForMultipleObjects+0x14
01 00000022`96eff0f0 00007ffd`e0ae3d98     KERNELBASE!WaitForMultipleObjectsEx+0xe9
02 00000022`96eff3d0 00007ffd`e0ae3a7c     coreclr!Thread::DoAppropriateAptStateWait+0x5c [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 3210] 
03 00000022`96eff410 00007ffd`e0ae36b8     coreclr!Thread::DoAppropriateWaitWorker+0x384 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 3389] 
04 00000022`96eff4e0 00007ffd`e0b752ab     coreclr!Thread::DoAppropriateWait+0xb8 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 3058] 
05 00000022`96eff580 00007ffd`e0b75118     coreclr!Thread::JoinEx+0x6b [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 423] 
06 00000022`96eff5d0 00007ffd`e0b74f7d     coreclr!ThreadNative::DoJoin+0xe0 [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp @ 761] 
07 00000022`96eff630 00007ffd`7c7cb6cf     coreclr!ThreadNative::Join+0xcd [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp @ 436] 
08 00000022`96eff7b0 00007ffe`40f35d45     System_Private_CoreLib!System.Threading.Thread.Join+0xf [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs @ 539] 
09 00000022`96eff7e0 00007ffd`80fe80b7     Microsoft_Win32_SystemEvents!Microsoft.Win32.SystemEvents.Shutdown+0x105 [/_/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs @ 1106] 
0a 00000022`96eff8e0 00007ffd`e0b84fc3     0x00007ffd`80fe80b7
0b 00000022`96eff930 00007ffd`e0a3d297     coreclr!CallDescrWorkerInternal+0x83 [D:\a\_work\1\s\src\coreclr\vm\amd64\CallDescrWorkerAMD64.asm @ 74] 
0c 00000022`96eff970 00007ffd`e0b2ac5b     coreclr!MethodDescCallSite::CallTargetWorker+0x21f [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp @ 557] 
0d (Inline Function) --------`--------     coreclr!MethodDescCallSite::Call+0x12 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.h @ 458] 
0e (Inline Function) --------`--------     coreclr!AppDomain::RaiseExitProcessEvent+0x2d [D:\a\_work\1\s\src\coreclr\vm\appdomain.cpp @ 3721] 
0f 00000022`96effab0 00007ffe`7cdc257d     coreclr!FinalizerThread::FinalizerThreadStart+0xcb [D:\a\_work\1\s\src\coreclr\vm\finalizerthread.cpp @ 472] 

So finalizer is blocked on closing the events thread, which is running.

And the events thread is blocked by WindowsFormsSynchronizationContext which is trying to send a message to a control that is not pumping messages. My understanding from the repro is that this particular control never even started up - so no UI thread, nothing to recieve the message being sent. IMO we still need a Winforms look here @JeremyKuhne @lonitra.

ericstj avatar Aug 07 '24 18:08 ericstj

Took a look and here is what I am observing so far: Typically when a Form is created a ThreadContext is created if one has not been created yet (UI thread?), which is what is checked in Control.WaitForWaitHandle. We are getting stuck in this loop. In WinForms apps we typically have a call to Application.Run(form) to make the form visible and start the message loop for the thread. This repro app does not ever start the message loop for the thread. But it has call SendMessageTimeout(0xffff) which sends a message to "all top-level windows in the system, including disabled or invisible unowned windows" and we get stuck from this... I am still trying to understand all the pieces here, but as Eric mentioned earlier in this issue thread, it seems we should see if there is a way for us to detect that message loop for thread has not start and work will never be done. Note that when I add Application.Run(form) and close the form. No hang occurs. cc: @JeremyKuhne

lonitra avatar Aug 08 '24 23:08 lonitra

I realize the specific repro is somewhat artificial and not necessarily the same thing we saw happening in the dumps from our customers. That said, it's still based on a pattern we use in our application. We do create our main form before Application.Run loop starts. In fact, you basically have to do that to be able to pass it to Application.Run(form), and we do have some error conditions where an error can happen between the point of the Form creation (and thus establishing the SynchronizationContext on the thread) and before Application.Run is called. Based on the information we got from the customers there's something that triggers the broadcasted messages on affected machines in somewhat consistent fashion during our app's lifecycle. We don't know what specifically triggers it, it could be some 3rd party app, like a screen reader.

filipnavara avatar Aug 09 '24 00:08 filipnavara

SystemEvents cannot know that the WindowsFormsSynchronizationContext is broken here and it's been established that it waits on finalization.

I think we need a fix in WindowsFormsSynchronizationContext to not block (either throw, or skip entirely) if it has no message loop running.

ericstj avatar Aug 20 '24 16:08 ericstj