Skip to content

[clr-ios] Fix exception handling for debugger interception#126955

Closed
kotlarmilos wants to merge 4 commits intodotnet:mainfrom
kotlarmilos:interp-followup-exceptions
Closed

[clr-ios] Fix exception handling for debugger interception#126955
kotlarmilos wants to merge 4 commits intodotnet:mainfrom
kotlarmilos:interp-followup-exceptions

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented Apr 15, 2026

Description

Fix exception handling paths for the interpreter debugger: detect interpreter-to-native transitions past the last interpreter frame in SfiNextWorker, and skip InterpreterFrame entries in the unhandled-exception frame chain walk.

Follow-up to #126576

This fixes the following interpreter debugger test failure:

  • Exceptions.InterceptTest

Copilot AI review requested due to automatic review settings April 15, 2026 17:10
@kotlarmilos kotlarmilos changed the title [Interpreter] Fix exception handling for debugger interception [clr-ios] Fix exception handling for debugger interception Apr 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes interpreter-related exception/debugger interaction issues (notably exception interception via SetIP) by adjusting EH stack-walking semantics for interpreted frames and enabling interpreter breakpoint handling to resume from debugger-modified IP, with supporting debugger/func-eval plumbing.

Changes:

  • Adjust EH stack-walk control PC handling and native-transition detection for interpreted frames, including skipping InterpreterFrame entries when checking for unhandled exceptions.
  • Update interpreter breakpoint handling to run pending interpreter func-evals and honor debugger SetIP changes when resuming execution.
  • Rename the func-eval flag from “during exception” to “uses hijack” across debugger + CDAC surface area.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/Frames/DebuggerEval.cs Renames CDAC-exposed flag to EvalUsesHijack in the reader contract.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/X86FrameHandler.cs Uses EvalUsesHijack to decide whether to update unwind context from DebuggerEval.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/BaseFrameHandler.cs Uses EvalUsesHijack to decide whether to update unwind context from DebuggerEval.
src/coreclr/vm/interpexec.cpp Returns updated bytecode IP from breakpoint callback and executes pending interpreter func-evals.
src/coreclr/vm/exceptionhandling.cpp Interpreter-aware EH stackwalk changes (controlPC adjust, transition detection, frame-chain skipping).
src/coreclr/vm/dbginterface.h Adds interpreter-specific debugger hook to execute pending interpreter func-evals.
src/coreclr/vm/datadescriptor/datadescriptor.inc Updates CDAC data descriptor field name to EvalUsesHijack.
src/coreclr/debug/ee/funceval.cpp Switches logic from m_evalDuringException to m_evalUsesHijack.
src/coreclr/debug/ee/debugger.h Renames DebuggerEval state to m_evalUsesHijack and adjusts Init behavior.
src/coreclr/debug/ee/debugger.cpp Interpreter-aware func-eval setup + new ExecutePendingInterpreterFuncEval implementation; updates to new flag name.

@kotlarmilos kotlarmilos added the os-ios Apple iOS label Apr 15, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread src/coreclr/debug/ee/debugger.cpp
Comment thread src/coreclr/debug/ee/debugger.cpp Outdated
Comment thread src/coreclr/vm/datadescriptor/datadescriptor.inc
kotlarmilos and others added 3 commits April 24, 2026 17:22
- Skip controlPC -1 adjustment for interpreter methods (bytecode IP already
  points to the correct instruction boundary)
- Detect native transitions past last interpreter frame in SfiNext
- Skip InterpreterFrame chain entries when checking for unhandled exceptions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rFrame skip

- Remove the IsInterpretedCode() skip around controlPC -= STACKWALK_CONTROLPC_ADJUST_OFFSET
  at both SfiInitWorker and SfiNextWorker exit. The throw-site case is already
  m_crawl.hasFaulted). The remaining propagation case needs the -1 because pFrame->ip
  is advanced past the call opcode before descending into the callee, same as a JIT
  return address, and EH clauses are half-open [tryStart, tryEnd).
- Change the InterpreterFrame skip in the isPropagatingToNativeCode branch from
  while to if. Only the one InterpreterFrame pushed by the just-unwound
  InterpExecMethod needs bridging; consuming adjacent InterpreterFrames could
  skip past an outer interpreted catch and incorrectly trigger the unhandled
  exception path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

@kotlarmilos kotlarmilos requested a review from noahfalk April 27, 2026 13:31
@kotlarmilos kotlarmilos requested a review from janvorli April 27, 2026 13:31
@kotlarmilos
Copy link
Copy Markdown
Member Author

isn't needed due to #127101, it suppress the debugger filter notification for the UCO entrypoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants