From 30c0d0ac33ad0e7abd54f209c082636e8e59b78c Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Mon, 4 May 2020 21:00:10 -0700 Subject: [PATCH] Fix a couple of Windows createdump issues (#35820) * Fix ERROR_PARTIAL_COPY retry. MiniDumpWriteDump sets the last error to the HRESULT instead of win32 error code * Fix createdump crash triggering on x86 runtime. The initialization code was in the wrong place and not being called on the x86 coreclr.dll. Moved it to early in EEStartupHelper. --- src/coreclr/src/debug/createdump/createdumpwindows.cpp | 4 ++-- src/coreclr/src/vm/ceemain.cpp | 5 +++++ src/coreclr/src/vm/exceptionhandling.cpp | 3 --- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/coreclr/src/debug/createdump/createdumpwindows.cpp b/src/coreclr/src/debug/createdump/createdumpwindows.cpp index 61e98ba..d806330 100644 --- a/src/coreclr/src/debug/createdump/createdumpwindows.cpp +++ b/src/coreclr/src/debug/createdump/createdumpwindows.cpp @@ -41,9 +41,9 @@ CreateDump(const char* dumpPath, int pid, MINIDUMP_TYPE minidumpType) else { int err = GetLastError(); - if (err != ERROR_PARTIAL_COPY) + if (err != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) { - fprintf(stderr, "Write dump FAILED %d\n", err); + fprintf(stderr, "Write dump FAILED 0x%08x\n", err); break; } } diff --git a/src/coreclr/src/vm/ceemain.cpp b/src/coreclr/src/vm/ceemain.cpp index 3b9ebeb..ee67d1e 100644 --- a/src/coreclr/src/vm/ceemain.cpp +++ b/src/coreclr/src/vm/ceemain.cpp @@ -644,6 +644,11 @@ void EEStartupHelper() IfFailGo(EEConfig::Setup()); #ifndef CROSSGEN_COMPILE + +#ifdef HOST_WINDOWS + InitializeCrashDump(); +#endif // HOST_WINDOWS + // Initialize Numa and CPU group information // Need to do this as early as possible. Used by creating object handle // table inside Ref_Initialization() before GC is initialized. diff --git a/src/coreclr/src/vm/exceptionhandling.cpp b/src/coreclr/src/vm/exceptionhandling.cpp index 1612f39..740678e 100644 --- a/src/coreclr/src/vm/exceptionhandling.cpp +++ b/src/coreclr/src/vm/exceptionhandling.cpp @@ -241,9 +241,6 @@ void InitializeExceptionHandling() // Register handler for termination requests (e.g. SIGTERM) PAL_SetTerminationRequestHandler(HandleTerminationRequest); #endif // TARGET_UNIX -#ifdef HOST_WINDOWS - InitializeCrashDump(); -#endif // HOST_WINDOWS } struct UpdateObjectRefInResumeContextCallbackState -- 2.7.4