我有一个控制台应用程序,有时在退出时会挂起。也许千分之一,它会挂起。当它挂起时,只剩下一个线程,它会消耗 100% 的 CPU。
如果我在 ProcessExplorer 中查看进程,当我转到 ProcessExplorer 的“线程”选项卡时,我的进程正常退出。
查看 WinDbg 中的挂起进程,调用堆栈如下所示:
. 0 Id: 830.d00 Suspend: 1 Teb: 000007ff`fffde000 Unfrozen
Start: MyHost!COM+_Entry_Point <PERF> (MyHost+0x71ee) (00000000`002571ee)
Priority: 0 Priority class: 16384 Affinity: ff
Child-SP RetAddr Call Site
00000000`003ddc50 000007fe`ec3f7646 System_EnterpriseServices_Wrapper_7feec3f0000!CRT_INIT+0x65
00000000`003ddc90 000007fe`f91a4485 System_EnterpriseServices_Wrapper_7feec3f0000!DllMainCRTStartup+0x126
00000000`003ddcd0 000007fe`f93f3281 mscoreei!CorDllMain+0x1f5
00000000`003ddd50 000007fe`f93f32cf MSCOREE!ShellShim__CorDllMain+0xe1
00000000`003ddd80 00000000`77a54371 MSCOREE!CorDllMain_Exported+0x37
00000000`003dddb0 00000000`77a54180 ntdll!LdrShutdownProcess+0x1db
00000000`003dded0 000007fe`f91926d2 ntdll!RtlExitUserProcess+0x90
00000000`003ddf00 000007fe`f9192848 mscoreei!RuntimeDesc::ShutdownAllActiveRuntimes+0x294
00000000`003de1f0 000007fe`f89cc919 mscoreei!CLRRuntimeHostInternalImpl::ShutdownAllRuntimesThenExit+0x14
00000000`003de220 000007fe`f897ef51 clr!EEPolicy::ExitProcessViaShim+0x69
00000000`003de270 000007fe`f8976776 clr!SafeExitProcess+0x9d
00000000`003de4e0 000007fe`f8d56971 clr!EEPolicy::GetFinalAction+0x9a
00000000`003de510 000007fe`f7b5f93b clr!SystemNative::Exit+0x52
00000000`003de560 000007fe`99142057 mscorlib_ni+0xcaf93b
00000000`003de630 000007fe`f87f07f3 0x7fe`99142057
00000000`003de900 000007fe`f87f02fe clr!CallDescrWorkerInternal+0x83
00000000`003de940 000007fe`f87f03c7 clr!CallDescrWorkerWithHandler+0x4a
00000000`003de980 000007fe`f892cdf0 clr!MethodDescCallSite::CallTargetWorker+0x2e6
00000000`003deb30 000007fe`f892d54e clr!RunMain+0x1e7
00000000`003ded00 000007fe`f892d448 clr!Assembly::ExecuteMainMethod+0xb6
00000000`003deff0 000007fe`f892cfc2 clr!SystemDomain::ExecuteMainMethod+0x45e
00000000`003df5b0 000007fe`f892cf0e clr!ExecuteEXE+0x3f
00000000`003df620 000007fe`f8929914 clr!CorExeMainInternal+0xae
00000000`003df6b0 000007fe`f91874e5 clr!CorExeMain+0x14
00000000`003df6f0 000007fe`f93e5b21 mscoreei!CorExeMain+0xe0
00000000`003df740 00000000`7782652d MSCOREE!CorExeMain_Exported+0x57
00000000`003df770 00000000`77a5c521 KERNEL32!BaseThreadInitThunk+0xd
00000000`003df7a0 00000000`00000000 ntdll!RtlUserThreadStart+0x1d
我怎样才能弄清楚这是在做什么?