如果堆分配/解除分配/重新分配正在另一个线程中进行,则 DbgHelp 库的 MiniDumpWriteDump() 会挂起。这是调用堆栈: DbgHelp 暂停其他线程,然后无限期地等待这些线程获得的互斥体。
ntdll.dll!NtWaitForAlertByThreadId() Unknown
ntdll.dll!RtlpWaitOnAddressWithTimeout() Unknown
ntdll.dll!RtlpWaitOnAddress() Unknown
ntdll.dll!RtlpWaitOnCriticalSection() Unknown
ntdll.dll!RtlpEnterCriticalSectionContended() Unknown
ntdll.dll!RtlEnterCriticalSection() Unknown
ntdll.dll!RtlpReAllocateHeap() Unknown
ntdll.dll!RtlpReAllocateHeapInternal() Unknown
ntdll.dll!RtlReAllocateHeap() Unknown
ntdll.dll!LdrpSetAlternateResourceModuleHandle() Unknown
ntdll.dll!LdrResGetRCConfig() Unknown
ntdll.dll!LdrpResSearchResourceMappedFile() Unknown
ntdll.dll!LdrResSearchResource() Unknown
KernelBase.dll!FindVersionResourceSafe() Unknown
> KernelBase.dll!GetFileVersionInfoSizeExW() Unknown
dbgcore.dll!Win32LiveSystemProvider::GetImageVersionInfo(void *,unsigned short const *,unsigned __int64,struct tagVS_FIXEDFILEINFO *) Unknown
dbgcore.dll!GenAllocateModuleObject(struct _MINIDUMP_STATE *,struct _INTERNAL_PROCESS *,unsigned short *,unsigned __int64,unsigned long,struct _INTERNAL_MODULE * *) Unknown
dbgcore.dll!GenGetProcessInfo(unsigned long,struct _MINIDUMP_STATE *,struct _INTERNAL_PROCESS * *,struct _LIST_ENTRY *) Unknown
dbgcore.dll!MiniDumpProvideDump() Unknown
dbgcore.dll!MiniDumpWriteDump() Unknown
您知道这种情况的简单解决方法吗?我可以看到将检查注入应用程序中所有其他线程的解决方法,以查看是否请求了核心转储,然后在没有获得互斥锁的地方暂停。但这是一个很大的变化,加上应用程序的一些线程是我无法控制的,因为它们是由我用于内部使用的库启动的。