Skip to content

Commit

Permalink
Fix exception interception on ARM64 with new EH (#100349)
Browse files Browse the repository at this point in the history
The interception stack frame was originally set to the caller SP on arm64,
but the checks in CallCatchFunclet and ExInfo::PopExInfos were using the
current frame SP instead. This change sets the interception frame to
the current frame SP on arm/arm64 too to fix the issue.
  • Loading branch information
janvorli authored Mar 28, 2024
1 parent e74f170 commit a5b9a6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11566,17 +11566,26 @@ HRESULT Debugger::GetAndSendInterceptCommand(DebuggerIPCEvent *event)
//
// Set up the VM side of intercepting.
//
StackFrame sfInterceptFramePointer;
if (g_isNewExceptionHandlingEnabled)
{
sfInterceptFramePointer = StackFrame::FromRegDisplay(&(csi.m_activeFrame.registers));
}
else
{
#if defined (TARGET_ARM )|| defined (TARGET_ARM64 )
// ARM requires the caller stack pointer, not the current stack pointer
sfInterceptFramePointer = CallerStackFrame::FromRegDisplay(&(csi.m_activeFrame.registers));
#else
sfInterceptFramePointer = StackFrame::FromRegDisplay(&(csi.m_activeFrame.registers));
#endif
}
if (pExState->GetDebuggerState()->SetDebuggerInterceptInfo(csi.m_activeFrame.pIJM,
pThread,
csi.m_activeFrame.MethodToken,
csi.m_activeFrame.md,
foundOffset,
#if defined (TARGET_ARM )|| defined (TARGET_ARM64 )
// ARM requires the caller stack pointer, not the current stack pointer
CallerStackFrame::FromRegDisplay(&(csi.m_activeFrame.registers)),
#else
StackFrame::FromRegDisplay(&(csi.m_activeFrame.registers)),
#endif
sfInterceptFramePointer,
pExState->GetFlags()
))
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/exceptionhandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8090,7 +8090,7 @@ static BOOL CheckExceptionInterception(StackFrameIterator* pStackFrameIterator,
reinterpret_cast<PBYTE *>(&(sfInterceptStackFrame.SP)),
NULL, NULL);

TADDR spForDebugger = GetSpForDiagnosticReporting(pStackFrameIterator->m_crawl.GetRegisterSet());
TADDR spForDebugger = GetRegdisplaySP(pStackFrameIterator->m_crawl.GetRegisterSet());

if ((pExInfo->m_passNumber == 1) ||
((pInterceptMD == pMD) && (sfInterceptStackFrame == spForDebugger)))
Expand Down

0 comments on commit a5b9a6a

Please sign in to comment.