Fix NotifyOfCHFFilter notification by advancing stackwalk iterator if in NATIVE_MARKER_FRAME state #127683
Open
tommcdon wants to merge 9 commits intodotnet:mainfrom
Open
Fix NotifyOfCHFFilter notification by advancing stackwalk iterator if in NATIVE_MARKER_FRAME state #127683tommcdon wants to merge 9 commits intodotnet:mainfrom
tommcdon wants to merge 9 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)
This reverts commit 0d2dd5e.
This reverts commit 5e376f1.
This reverts commit 3dfca14.
…SfiNextWorker" This reverts commit a8f2739.
… the stack frame iterator returns an extra NATIVE_MARKER_FRAME in between. The fix is to advance once frame past the marker frame to the explicit frame, which will trigger NotifyOfCHFFilter. Co-authored-by: Jan Vorlicek <janvorli@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Updated fix per feedback from JanVorli:
When there is a transition from a managed frame to an explicit frame, the stack frame iterator returns an extra NATIVE_MARKER_FRAME in between. The fix is to advance once frame past the marker frame to the explicit frame, which will trigger NotifyOfCHFFilter.
Found using internal Visual Studio testing
Fixes #125777