未验证 提交 80adff83 编写于 作者: J Jakob Botsch Nielsen 提交者: GitHub

Fix unsigned indexing with negative value on EnC (#72255)

FixContextForEnC was treating an index that may be negative as an
unsigned value. This would crash the runtime during EnC when running as
64-bit.

Fix #70834
上级 46bf30eb
......@@ -991,6 +991,7 @@ HRESULT EECodeManager::FixContextForEnC(PCONTEXT pCtx,
UINT32 oldSizeOfPreservedArea = oldGcDecoder.GetSizeOfEditAndContinuePreservedArea();
UINT32 newSizeOfPreservedArea = newGcDecoder.GetSizeOfEditAndContinuePreservedArea();
LOG((LF_CORDB, LL_INFO100, "EECM::FixContextForEnC: Got old and new EnC preserved area sizes of %u and %u\n", oldSizeOfPreservedArea, newSizeOfPreservedArea));
// This ensures the JIT generated EnC compliant code.
if ((oldSizeOfPreservedArea == NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA) ||
(newSizeOfPreservedArea == NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA))
......@@ -1001,6 +1002,8 @@ HRESULT EECodeManager::FixContextForEnC(PCONTEXT pCtx,
TADDR oldStackBase = GetSP(&oldCtx);
LOG((LF_CORDB, LL_INFO100, "EECM::FixContextForEnC: Old SP=%p, FP=%p\n", (void*)oldStackBase, (void*)GetFP(&oldCtx)));
#if defined(TARGET_AMD64)
// Note: we cannot assert anything about the relationship between oldFixedStackSize
// and newFixedStackSize. It's possible the edited frame grows (new locals) or
......@@ -1013,6 +1016,8 @@ HRESULT EECodeManager::FixContextForEnC(PCONTEXT pCtx,
_ASSERTE(pOldCodeInfo->HasFrameRegister());
_ASSERTE(pNewCodeInfo->HasFrameRegister());
LOG((LF_CORDB, LL_INFO100, "EECM::FixContextForEnC: Old and new fixed stack sizes are %u and %u\n", oldFixedStackSize, newFixedStackSize));
// x64: SP == FP before localloc
if (oldStackBase != GetFP(&oldCtx))
return E_FAIL;
......@@ -1020,6 +1025,8 @@ HRESULT EECodeManager::FixContextForEnC(PCONTEXT pCtx,
DWORD oldFixedStackSize = oldGcDecoder.GetSizeOfEditAndContinueFixedStackFrame();
DWORD newFixedStackSize = newGcDecoder.GetSizeOfEditAndContinueFixedStackFrame();
LOG((LF_CORDB, LL_INFO100, "EECM::FixContextForEnC: Old and new fixed stack sizes are %u and %u\n", oldFixedStackSize, newFixedStackSize));
// ARM64: FP + 16 == SP + oldFixedStackSize before localloc
if (GetFP(&oldCtx) + 16 != oldStackBase + oldFixedStackSize)
return E_FAIL;
......@@ -1128,7 +1135,7 @@ HRESULT EECodeManager::FixContextForEnC(PCONTEXT pCtx,
if (pOldVar->startOffset <= oldMethodOffset &&
pOldVar->endOffset > oldMethodOffset)
{
oldMethodVarsSorted[varNumber] = *pOldVar;
oldMethodVarsSorted[(int)varNumber] = *pOldVar;
}
}
......@@ -1180,7 +1187,7 @@ HRESULT EECodeManager::FixContextForEnC(PCONTEXT pCtx,
if (pNewVar->startOffset <= newMethodOffset &&
pNewVar->endOffset > newMethodOffset)
{
newMethodVarsSorted[varNumber] = *pNewVar;
newMethodVarsSorted[(int)varNumber] = *pNewVar;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册