Skip to content
Merged
Changes from 2 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
18 changes: 17 additions & 1 deletion src/coreclr/vm/threadsuspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,18 @@ void RedirectedThreadFrame::ExceptionUnwind()
#ifndef TARGET_UNIX

#ifdef TARGET_X86

// a helper to make sure these calls are not inlined into a filter function.
// in particular we do not want a possibility of inlined destructor calls.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a concern once you change it to EEPOLICY_HANDLE_FATAL_ERROR. EEPOLICY_HANDLE_FATAL_ERROR is non-inlineable.

NOINLINE void CopyContextHelper(CONTEXT* pTarget, CONTEXT* pCtx)
{
if (!CopyContext(pTarget, pTarget->ContextFlags, pCtx))
{
STRESS_LOG1(LF_SYNC, LL_ERROR, "ERROR: Could not set context record, lastError = 0x%x\n", GetLastError());
ThrowLastError();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ThrowLastError();
EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE);

The caller does not expect exceptions. This needs to be failfast. Throwing exception is likely going to lead to hard to diagnose crash otherwise.

}
}

//****************************************************************************************
// 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 +2589,11 @@ 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;
CopyContextHelper(pTarget, pCtx);

DWORD espValue = pCtx->Esp;

Expand Down