From 04b4f4c8f54d3f7dfd5fa244d702f3b46c4daf98 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Wed, 1 Sep 2021 13:52:16 -0700 Subject: [PATCH] Fix dump generation segfault in DAC Issue: https://github.com/dotnet/runtime/issues/58525 --- src/coreclr/vm/excep.cpp | 3 ++- src/coreclr/vm/exceptmacros.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index 5249ea70661e0d..a6bf9884a2d138 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -11533,8 +11533,9 @@ VOID ThrowBadFormatWorker(UINT resID, LPCWSTR imageName DEBUGARG(__in_z const ch msgStr += W(")"); } #endif - ThrowHR(COR_E_BADIMAGEFORMAT, msgStr); +#else // DACCESS_COMPILE + ThrowHR(COR_E_BADIMAGEFORMAT); #endif // #ifndef DACCESS_COMPILE } diff --git a/src/coreclr/vm/exceptmacros.h b/src/coreclr/vm/exceptmacros.h index 7e3a058f7b2b6b..3fefb7936069a4 100644 --- a/src/coreclr/vm/exceptmacros.h +++ b/src/coreclr/vm/exceptmacros.h @@ -515,8 +515,12 @@ template NOINLINE VOID ThrowBadFormatWorkerT(UINT resID, T * pImgObj DEBUGARG(__in_z const char *cond)) { +#ifdef DACCESS_COMPILE + ThrowBadFormatWorker(resID, nullptr DEBUGARG(cond)); +#else LPCWSTR tmpStr = GetPathForErrorMessagesT(pImgObj); ThrowBadFormatWorker(resID, tmpStr DEBUGARG(cond)); +#endif }