From 1c963b8694365c7e31605fda0939fe7564c38716 Mon Sep 17 00:00:00 2001 From: Konstantin Baladurin Date: Fri, 29 Sep 2017 11:08:01 +0300 Subject: [PATCH] Fix assert in HelperMethodFrame::UpdateRegDisplay (#14235) In some cases during execution of the SOS command 'clrstack -i' portability assert in HelperMethodFrame::UpdateRegDisplay occurs. This patch removes this assert and adds corresponding implementation. --- src/vm/i386/cgenx86.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/vm/i386/cgenx86.cpp b/src/vm/i386/cgenx86.cpp index ca81bb7..b4277db 100644 --- a/src/vm/i386/cgenx86.cpp +++ b/src/vm/i386/cgenx86.cpp @@ -379,7 +379,30 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD) pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. #ifdef DACCESS_COMPILE - PORTABILITY_ASSERT("HelperMethodFrame::UpdateRegDisplay"); + // For DAC, we may get here when the HMF is still uninitialized. + // So we may need to unwind here. + if (!m_MachState.isValid()) + { + // This allocation throws on OOM. + MachState* pUnwoundState = (MachState*)DacAllocHostOnlyInstance(sizeof(*pUnwoundState), true); + + InsureInit(false, pUnwoundState); + + pRD->pCurrentContext->Eip = pRD->ControlPC = pUnwoundState->GetRetAddr(); + pRD->pCurrentContext->Esp = pRD->SP = pUnwoundState->esp(); + +#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = *((DWORD*) pUnwoundState->p##regname()); + ENUM_CALLEE_SAVED_REGISTERS(); +#undef CALLEE_SAVED_REGISTER + +#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContextPointers->regname = (DWORD*) pUnwoundState->p##regname(); + ENUM_CALLEE_SAVED_REGISTERS(); +#undef CALLEE_SAVED_REGISTER + + ClearRegDisplayArgumentAndScratchRegisters(pRD); + + return; + } #endif // DACCESS_COMPILE pRD->pCurrentContext->Eip = pRD->ControlPC = m_MachState.GetRetAddr(); -- 2.7.4