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

Fix VS issue with unhandled exception on secondary threads #103425

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
14 changes: 9 additions & 5 deletions src/coreclr/vm/exceptionhandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8213,6 +8213,11 @@ void FailFastIfCorruptingStateException(ExInfo *pExInfo)
}
}

static bool IsTopmostDebuggerU2MCatchHandlerFrame(Frame *pFrame)
{
return (pFrame->GetVTablePtr() == DebuggerU2MCatchHandlerFrame::GetMethodFrameVPtr()) && (pFrame->PtrNextFrame() == FRAME_TOP);
}

static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThread, ExInfo *pExInfo)
{
if (pExInfo->m_passNumber == 1)
Expand Down Expand Up @@ -8289,7 +8294,7 @@ static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThrea
pFrame = pFrame->PtrNextFrame();
_ASSERTE(pFrame != FRAME_TOP);
}
if ((pFrame->GetVTablePtr() == FuncEvalFrame::GetMethodFrameVPtr()) || (pFrame->GetVTablePtr() == DebuggerU2MCatchHandlerFrame::GetMethodFrameVPtr()))
if ((pFrame->GetVTablePtr() == FuncEvalFrame::GetMethodFrameVPtr()) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame))
{
EEToDebuggerExceptionInterfaceWrapper::NotifyOfCHFFilter((EXCEPTION_POINTERS *)&pExInfo->m_ptrs, pFrame);
}
Expand Down Expand Up @@ -8518,9 +8523,6 @@ extern "C" bool QCALLTYPE SfiNext(StackFrameIterator* pThis, uint* uExCollideCla
}
else
{
// TODO-NewEH: Currently there is one case of internal VM->managed transitions: COMToCLRDispatchHelperWithStack
// Either add handling here as well or rewrite it in C#, so that CallDescrWorker is the only path that
// needs to be handled here.
size_t CallDescrWorkerInternalReturnAddress = (size_t)CallDescrWorkerInternal + CallDescrWorkerInternalReturnAddressOffset;
if (GetIP(pThis->m_crawl.GetRegisterSet()->pCallerContext) == CallDescrWorkerInternalReturnAddress)
{
Expand All @@ -8544,7 +8546,9 @@ extern "C" bool QCALLTYPE SfiNext(StackFrameIterator* pThis, uint* uExCollideCla
_ASSERTE(retVal != SWA_FAILED);
_ASSERTE(pThis->GetFrameState() != StackFrameIterator::SFITER_SKIPPED_FRAME_FUNCTION);

if (pThis->m_crawl.GetFrame() == FRAME_TOP)
pFrame = pThis->m_crawl.GetFrame();
// Check if there are any further managed frames on the stack, if not, the exception is unhandled.
if ((pFrame == FRAME_TOP) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame))
{
if (pTopExInfo->m_passNumber == 1)
{
Expand Down
Loading