From c2638fc2855681d3498dce10c8cbb5f0c380f8d6 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Sat, 19 Apr 2025 12:27:22 -0700 Subject: [PATCH 1/4] Move m_Context to the end of SoftwareExceptionFrame to fix cross-DAC --- src/coreclr/vm/frames.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 2c451984354ae8..4eb2206a993d09 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -1041,8 +1041,8 @@ typedef DPTR(class SoftwareExceptionFrame) PTR_SoftwareExceptionFrame; class SoftwareExceptionFrame : public Frame { TADDR m_ReturnAddress; - T_CONTEXT m_Context; T_KNONVOLATILE_CONTEXT_POINTERS m_ContextPointers; + T_CONTEXT m_Context; public: #ifndef DACCESS_COMPILE From ce3ac73a4994ebf967b96ce71a2ebbdc855cab67 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Mon, 21 Apr 2025 11:05:06 -0700 Subject: [PATCH 2/4] Add comments and fix FaultingExceptionFrame on amd64 --- src/coreclr/vm/amd64/asmconstants.h | 4 ++-- src/coreclr/vm/frames.h | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index 9f4e3543dfaad6..63604f5566576c 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -449,11 +449,11 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__VectorRegister ASMCONSTANTS_C_ASSERT(SIZEOF__FaultingExceptionFrame == sizeof(FaultingExceptionFrame)); -#define OFFSETOF__FaultingExceptionFrame__m_fFilterExecuted 0x10 +#define OFFSETOF__FaultingExceptionFrame__m_fFilterExecuted (SIZEOF__Frame + 0x8) ASMCONSTANTS_C_ASSERT(OFFSETOF__FaultingExceptionFrame__m_fFilterExecuted == offsetof(FaultingExceptionFrame, m_fFilterExecuted)); -#define OFFSETOF__FaultingExceptionFrame__m_SSP (0x20 + SIZEOF__CONTEXT) +#define OFFSETOF__FaultingExceptionFrame__m_SSP (SIZEOF__Frame) ASMCONSTANTS_C_ASSERT(OFFSETOF__FaultingExceptionFrame__m_SSP == offsetof(FaultingExceptionFrame, m_SSP)); diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 4eb2206a993d09..f1c95793087a2d 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -933,6 +933,10 @@ class FaultingExceptionFrame : public Frame { friend class CheckAsmOffsets; +#ifdef TARGET_AMD64 + TADDR m_SSP; +#endif + #ifndef FEATURE_EH_FUNCLETS #ifdef TARGET_X86 DWORD m_Esp; @@ -944,13 +948,11 @@ class FaultingExceptionFrame : public Frame #else // FEATURE_EH_FUNCLETS BOOL m_fFilterExecuted; // Flag for FirstCallToHandler TADDR m_ReturnAddress; + // This T_CONTEXT field needs to be the last field in the class because it is a + // different size between Linux (pal.h) and the Windows cross-DAC (winnt.h). T_CONTEXT m_ctx; #endif // !FEATURE_EH_FUNCLETS -#ifdef TARGET_AMD64 - TADDR m_SSP; -#endif - public: #ifndef DACCESS_COMPILE FaultingExceptionFrame() : Frame(FrameIdentifier::FaultingExceptionFrame) { @@ -1042,6 +1044,8 @@ class SoftwareExceptionFrame : public Frame { TADDR m_ReturnAddress; T_KNONVOLATILE_CONTEXT_POINTERS m_ContextPointers; + // This T_CONTEXT field needs to be the last field in the class because it is a + // different size between Linux (pal.h) and the Windows cross-DAC (winnt.h). T_CONTEXT m_Context; public: From 376d5ac28f84bb3e630738d490da5f8ea9dda364 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Tue, 22 Apr 2025 09:53:44 -0700 Subject: [PATCH 3/4] Fix debug assert in DBI --- src/coreclr/debug/ee/debugger.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 48041a442ac015..3737d94a4e7177 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -2774,6 +2774,13 @@ DebuggerMethodInfo *Debugger::GetOrCreateMethodInfo(Module *pModule, mdMethodDef } CONTRACTL_END; +#ifdef DACCESS_COMPILE + if (!HasLazyData()) + { + return NULL; + } +#endif // #ifdef DACCESS_COMPILE + DebuggerMethodInfo *info = NULL; // When dump debugging, we don't expect to have a lock, From 58416d2bf66d11a243263a5eb3e908020d444722 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Mon, 21 Apr 2025 16:15:57 -0700 Subject: [PATCH 4/4] Back out FaultingExceptionFrame changes --- src/coreclr/vm/amd64/asmconstants.h | 4 ++-- src/coreclr/vm/frames.h | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index 63604f5566576c..9f4e3543dfaad6 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -449,11 +449,11 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__VectorRegister ASMCONSTANTS_C_ASSERT(SIZEOF__FaultingExceptionFrame == sizeof(FaultingExceptionFrame)); -#define OFFSETOF__FaultingExceptionFrame__m_fFilterExecuted (SIZEOF__Frame + 0x8) +#define OFFSETOF__FaultingExceptionFrame__m_fFilterExecuted 0x10 ASMCONSTANTS_C_ASSERT(OFFSETOF__FaultingExceptionFrame__m_fFilterExecuted == offsetof(FaultingExceptionFrame, m_fFilterExecuted)); -#define OFFSETOF__FaultingExceptionFrame__m_SSP (SIZEOF__Frame) +#define OFFSETOF__FaultingExceptionFrame__m_SSP (0x20 + SIZEOF__CONTEXT) ASMCONSTANTS_C_ASSERT(OFFSETOF__FaultingExceptionFrame__m_SSP == offsetof(FaultingExceptionFrame, m_SSP)); diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index f1c95793087a2d..6444b6ee776124 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -933,10 +933,6 @@ class FaultingExceptionFrame : public Frame { friend class CheckAsmOffsets; -#ifdef TARGET_AMD64 - TADDR m_SSP; -#endif - #ifndef FEATURE_EH_FUNCLETS #ifdef TARGET_X86 DWORD m_Esp; @@ -948,11 +944,13 @@ class FaultingExceptionFrame : public Frame #else // FEATURE_EH_FUNCLETS BOOL m_fFilterExecuted; // Flag for FirstCallToHandler TADDR m_ReturnAddress; - // This T_CONTEXT field needs to be the last field in the class because it is a - // different size between Linux (pal.h) and the Windows cross-DAC (winnt.h). T_CONTEXT m_ctx; #endif // !FEATURE_EH_FUNCLETS +#ifdef TARGET_AMD64 + TADDR m_SSP; +#endif + public: #ifndef DACCESS_COMPILE FaultingExceptionFrame() : Frame(FrameIdentifier::FaultingExceptionFrame) {