From 738b8c71dbb6928bfcf8880ddbe64fc801d0322b Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Thu, 25 Apr 2024 14:08:10 +0200 Subject: [PATCH] Avoid overwriting frame context in JIT_Patchpoint Hopefully will help with diagnosing #101060 once we get a new dump. --- src/coreclr/vm/jithelpers.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 7400708001589..35d92c8791ba8 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -5144,7 +5144,7 @@ void JIT_Patchpoint(int* counter, int ilOffset) const int counterBump = g_pConfig->OSR_CounterBump(); *counter = counterBump; -#if _DEBUG +#ifdef _DEBUG const int ppId = ppInfo->m_patchpointId; #endif @@ -5316,9 +5316,18 @@ void JIT_Patchpoint(int* counter, int ilOffset) InitializeContext(pBuffer, contextFlags, &pFrameContext, &contextSize); _ASSERTE(success); #else // TARGET_WINDOWS && TARGET_AMD64 + +#ifdef _DEBUG + // Temporary change to avoid the frame context being overwritten after + // a crash after transition + pFrameContext = (CONTEXT*)_alloca(sizeof(CONTEXT) + 0x40000); +#else CONTEXT frameContext; - frameContext.ContextFlags = CONTEXT_FULL; pFrameContext = &frameContext; +#endif + + pFrameContext->ContextFlags = CONTEXT_FULL; + #endif // TARGET_WINDOWS && TARGET_AMD64 // Find context for the original method