Deadlock dbghelp.dll!MiniDumpWriteDump RRS feed

  • Question

  • I've faced a problem. It's not a regular deadlock, it can happen spontaneously.

    The problem is that a thread caused an unhandled exception can deadlock itself. The exception was processed by my UnhandledExceptionFilterThunk, where I called MiniDumpWriteDump. 

    I suppose that MiniDumpWriteDump suspends all the threads in the process and than calls RtlReAllocateHeap. There is a possibility that one of the suspended threads was allocating heap when it was suspended. This can cause a deadlock. This problem still exists in Windows 7 and later versions.

    Here is a stack of the thread caused the problem:

      version.dll!FindVersionResourceSafe(int,struct HINSTANCE__ *,unsigned long *)
      dbghelp.dll!Win32LiveSystemProvider::GetImageVersionInfo(void *,unsigned short const *,unsigned __int64,struct tagVS_FIXEDFILEINFO *)
      dbghelp.dll!GenAllocateModuleObject(struct _MINIDUMP_STATE *,struct _INTERNAL_PROCESS *,unsigned short *,unsigned __int64,unsigned long,struct _INTERNAL_MODULE * *)
      dbghelp.dll!GenGetProcessInfo(struct _MINIDUMP_STATE *,struct _INTERNAL_PROCESS * *)
      core83.dll!core::WriteDump(_MINIDUMP_TYPE eType, const stlp_std::basic_string<wchar_t,stlp_std::char_traits<wchar_t>,stlp_std::allocator<wchar_t> > & dumpFileName, _EXCEPTION_POINTERS * lpExpPtrs) Line 260 C++
      core83.dll!core::DoExceptionFilter(_EXCEPTION_POINTERS * pExceptionInfo) Line 185   core83.dll!core::ExceptionFilterThunk2(_EXCEPTION_POINTERS * pExceptionInfo) Line 131

    This is really rare situation and there'is no any correlations found between a reason caused the exception and this deadlock.

    We made a bypass of this problem by calling MiniDumpWriteDump from another process. 

    Wednesday, May 21, 2014 6:32 AM

All replies

  • This is a note for the future me.

    Microsoft recommends that MiniDumpWriteDump should not be called from within the target process being dumped:

    MiniDumpWriteDump will suspend all threads before doing the minidump. This means if any suspended thread is holding a lock, then it might deadlock the one writing the dump.

    Forexample a thread is allocating alot of memory, and has taken the global lock to increase the process heap. If that thread becomes suspended, then it will be impossible for the thread writing the dump to allocate any more memory.

    Tuesday, November 13, 2018 6:59 PM