Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CopyContext to restore saved context on X86 #65490

Merged
merged 3 commits into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/coreclr/vm/threadsuspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,7 @@ void RedirectedThreadFrame::ExceptionUnwind()
#ifndef TARGET_UNIX

#ifdef TARGET_X86

//****************************************************************************************
// This will check who caused the exception. If it was caused by the the redirect function,
// the reason is to resume the thread back at the point it was redirected in the first
Expand Down Expand Up @@ -2577,7 +2578,15 @@ int RedirectedHandledJITCaseExceptionFilter(
pFrame->Pop();

// Copy the saved context record into the EH context;
ReplaceExceptionContextRecord(pExcepPtrs->ContextRecord, pCtx);
// NB: cannot use ReplaceExceptionContextRecord here.
// these contexts may contain extended registers and may have different format
// for reasons such as alignment or context compaction
CONTEXT* pTarget = pExcepPtrs->ContextRecord;
if (!CopyContext(pTarget, pTarget->ContextFlags, pCtx))
{
STRESS_LOG1(LF_SYNC, LL_ERROR, "ERROR: Could not set context record, lastError = 0x%x\n", GetLastError());
EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE);
}

DWORD espValue = pCtx->Esp;

Expand Down