Finalizer bloqued 挂起应用程序

Finalizer bloqued hanging the application

今天我们收到了挂起的应用程序的 CrashDump。 运行 通过 DebugDiag 我们得到了以下信息:

Analysis Summary

Error

Description Recommendation

The finalizer thread 5 in this WordHangs.dmp is blocked Review the callstack for the Finalizer thread to see what the finalizer is blocked on. Long running code on a Finalizer thread can increase the number of objects ready for finalization and is bad for the overall memory consumption of the process

查看线程 5,我们无法确定线程在做什么。调用堆栈如下:

Thread 5 - System ID 13636

Entry point clr!Thread::intermediateThreadProc Create time
19/04/2017 9:32:59 Time spent in user mode 0 Days 00:00:00.093 Time spent in kernel mode 0 Days 00:00:00.078

This thread is not fully resolved and may or may not be a problem. Further analysis of these threads may be required.

.NET Call Stack

[[DebuggerU2MCatchHandlerFrame]]

Full Call Stack

Source

ntdll!NtWaitForSingleObject+15 KERNELBASE!WaitForSingleObjectEx+98 kernel32!WaitForSingleObjectExImplementation+75
clr!CLREventBase::Reset+145 clr!CLREventBase::Reset+18d
clr!CLREventBase::WaitEx+152 clr!CLREventBase::Wait+1a
clr!Thread::WaitSuspendEventsHelper+8a
clr!Thread::WaitSuspendEvents+14
clr!Thread::RareEnablePreemptiveGC+8e
clr!Thread::RareDisablePreemptiveGC+102
clr!WKS::GCHeap::FinalizerThreadWorker+1b5
clr!Thread::DoExtraWorkForFinalizer+1bd
clr!Thread::DoExtraWorkForFinalizer+240
clr!Thread::DoExtraWorkForFinalizer+5f0
[[DebuggerU2MCatchHandlerFrame]]
clr!WKS::GCHeap::FinalizerThreadStart+1a0
clr!Thread::intermediateThreadProc+4d
kernel32!BaseThreadInitThunk+e ntdll!__RtlUserThreadStart+70
ntdll!_RtlUserThreadStart+1b

我们已在加载 SOSEX 的情况下执行 Windb 以识别任何死锁,但没有成功。这是生成的输出:

0:000> !dlk Examining SyncBlocks... Scanning for

ReaderWriterLock(Slim) instances... Scanning for holders of

ReaderWriterLock locks... Scanning for holders of ReaderWriterLockSlim

locks... Examining CriticalSections... Scanning for threads waiting on

SyncBlocks... Scanning for threads waiting on ReaderWriterLock

locks... Scanning for threads waiting on ReaderWriterLocksSlim

locks... Scanning for threads waiting on CriticalSections...

*** ERROR: Symbol file could not be found. Defaulted to export symbols for MSO.DLL -

*** ERROR: Symbol file could not be found. Defaulted to export symbols for VSTOLoader.dll -

*** ERROR: Symbol file could not be found. Defaulted to export symbols for WWLIB.DLL -

*** ERROR: Symbol file could not be found. Defaulted to export symbols for WINWORD.EXE -

*** ERROR: Symbol file could not be found. Defaulted to export symbols for Csi.dll -

*** WARNING: Unable to verify checksum for aetpkss1.dll

*** ERROR: Symbol file could not be found. Defaulted to export symbols for aetpkss1.dll -

No deadlocks detected.

任何人都可以告诉我们在哪里查找以确定终结器线程被阻塞的原因吗?

在代码中我们进行了以下调用:

        GC.Collect();
        GC.WaitForPendingFinalizers();
        GC.Collect();
        GC.WaitForPendingFinalizers();

因为我们在这个问题之后删除了它:

Is correct to use GC.Collect(); GC.WaitForPendingFinalizers();?

问题已经解决,所以我猜这与此有关(可能这不仅仅是罪魁祸首,其他代码也相关)。