Move FuncEvalFrame/DebuggerU2MCatchHandlerFrame detection to SfiNextWorker#127683
Open
tommcdon wants to merge 4 commits intodotnet:mainfrom
Open
Move FuncEvalFrame/DebuggerU2MCatchHandlerFrame detection to SfiNextWorker#127683tommcdon wants to merge 4 commits intodotnet:mainfrom
tommcdon wants to merge 4 commits intodotnet:mainfrom
Conversation
…orker The FuncEvalFrame and DebuggerU2MCatchHandlerFrame detection in NotifyExceptionPassStarted relied on stale StackFrameIterator state from the end of pass 1. The iterator is no longer guaranteed to be in SFITER_FRAME_FUNCTION state at that point, causing the debugger to never receive the CATCH_HANDLER_FOUND notification during func eval. Move the check to SfiNextWorker where it runs during pass 1 at the native transition boundary with live iterator state and direct access to the frame chain. This matches the original design intent from PR dotnet#102470. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a debugger notification regression for exceptions thrown during func eval by moving FuncEvalFrame / DebuggerU2MCatchHandlerFrame detection from NotifyExceptionPassStarted (which could observe stale StackFrameIterator state after pass 1) into SfiNextWorker, where the check runs during pass 1 at the native-transition boundary with live iterator state and direct access to the explicit frame chain.
Changes:
- Removed FuncEvalFrame / DebuggerU2MCatchHandlerFrame detection from
NotifyExceptionPassStartedwhereStackFrameIteratorstate could be stale. - Added pass-1 native-transition-time detection in
SfiNextWorkerand issuesNotifyOfCHFFilterwhen the next explicit frame isFuncEvalFrame(skippingProtectValueClassFrame) or the topmostDebuggerU2MCatchHandlerFrame.
This was referenced May 2, 2026
Open
jkotas
reviewed
May 2, 2026
jkotas
reviewed
May 2, 2026
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/coreclr/vm/exceptionhandling.cpp:3657
- The
NotifyExceptionPassStartedpass-2 branch now has anelse {for the reverse-pinvoke case that appears to be missing the expected closing braces for the enclosingelse // passNumber == 2block / function. As written, the brace structure around this emptyelseblock doesn’t look balanced and would fail to compile. Please ensure the reverse-pinvokeelseblock is properly closed and the surrounding scopes are correctly terminated (or remove the emptyelseentirely if it’s no longer needed).
}
}
NOINLINE static void NotifyFunctionEnterHelper(StackFrameIterator *pThis, Thread *pThread, ExInfo *pExInfo)
Comment on lines
3654
to
3656
| } | ||
| } | ||
|
|
Comment on lines
+4031
to
+4037
| pNotifyFrame = pNotifyFrame->PtrNextFrame(); | ||
| _ASSERTE(pNotifyFrame != FRAME_TOP); | ||
| } | ||
| if ((pNotifyFrame->GetFrameIdentifier() == FrameIdentifier::FuncEvalFrame) || IsTopmostDebuggerU2MCatchHandlerFrame(pNotifyFrame)) | ||
| { | ||
| EEToDebuggerExceptionInterfaceWrapper::NotifyOfCHFFilter((EXCEPTION_POINTERS *)&pTopExInfo->m_ptrs, pNotifyFrame); | ||
| } |
| if (pNotifyFrame->GetFrameIdentifier() == FrameIdentifier::ProtectValueClassFrame) | ||
| { | ||
| pNotifyFrame = pNotifyFrame->PtrNextFrame(); | ||
| _ASSERTE(pNotifyFrame != FRAME_TOP); |
Comment on lines
+4019
to
+4020
| // explicit frame is a FuncEvalFrame or DebuggerU2MCatchHandlerFrame. The debugger needs this notification | ||
| // while the managed stack frames are still present so it can inspect the failure location. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The FuncEvalFrame and DebuggerU2MCatchHandlerFrame detection in NotifyExceptionPassStarted relied on stale StackFrameIterator state from the end of pass 1. The iterator is no longer guaranteed to be in SFITER_FRAME_FUNCTION state at that point, causing the debugger to never receive the CATCH_HANDLER_FOUND notification during func eval.
Move the check to SfiNextWorker where it runs during pass 1 at the native transition boundary with live iterator state and direct access to the frame chain.
Found using internal Visual Studio testing
Fixes #125777