Skip to content

[clr-interp] Fix debugger MethodEnter counter and INTOP_DEBUG_METHOD_ENTER assert - #127753

Merged
kotlarmilos merged 1 commit into
dotnet:mainfrom
kotlarmilos:interp-debug-callback-correctness
May 12, 2026
Merged

[clr-interp] Fix debugger MethodEnter counter and INTOP_DEBUG_METHOD_ENTER assert#127753
kotlarmilos merged 1 commit into
dotnet:mainfrom
kotlarmilos:interp-debug-callback-correctness

Conversation

@kotlarmilos

@kotlarmilos kotlarmilos commented May 4, 2026

Copy link
Copy Markdown
Member

Description

In DispatchMethodEnter, g_cTotalMethodEnter is supposed to count every controller with MethodEnter enabled regardless of which thread will actually fire the trigger. The increment was inside the per-thread filter, so unbound controllers were not counted, and the post-loop _ASSERTE(g_cTotalMethodEnter == count) fired. Move ++count out of the filter.

In the interpreter dispatch loop, INTOP_DEBUG_METHOD_ENTER asserts that the seq-point offset patched into the bytecode by OnMethodEnter is INTOP_DEBUG_SEQ_POINT. Once the debugger sets a user breakpoint at that sequence point the opcode is overwritten with INTOP_BREAKPOINT, which is also valid here, so the assert is updated to support such cases.

This fixes the following interpreter debugger test failures:

  • JMC.jmcChange
  • JMC.jmcDelegates
  • JMC.jmcFunceval
  • Async.AsyncStepInto

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

…R assert

Two small interpreter-debugger callback correctness fixes. In DispatchMethodEnter, g_cTotalMethodEnter is supposed to count every controller with MethodEnter enabled regardless of which thread will actually fire the trigger. The increment was inside the per-thread filter, so unbound and other-thread controllers were not counted, and the post-loop _ASSERTE(g_cTotalMethodEnter == count) fired spuriously. Move ++count out of the filter. The trigger itself remains gated on thread affinity.

In the interpreter dispatch loop, INTOP_DEBUG_METHOD_ENTER asserts that the seq-point offset patched into the bytecode by OnMethodEnter is INTOP_DEBUG_SEQ_POINT. Once the debugger sets a user breakpoint at that sequence point the opcode is overwritten with INTOP_BREAKPOINT, which is also valid here, so the assert is relaxed to accept either.

This fixes the following interpreter debugger test failures:
- JMC.jmcChange
- JMC.jmcDelegates
- JMC.jmcFunceval
- Async.AsyncStepInto

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kotlarmilos
kotlarmilos force-pushed the interp-debug-callback-correctness branch from 3a75885 to f0e5112 Compare May 4, 2026 14:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two debug-time assertions in the CoreCLR interpreter + debugger integration that were causing interpreter debugger test failures when MethodEnter controllers are thread-affinitized and when the debugger installs a breakpoint on the method-entry sequence point.

Changes:

  • Fix DispatchMethodEnter’s debug-only controller counting so it matches g_cTotalMethodEnter regardless of per-thread filtering.
  • Update the interpreter INTOP_DEBUG_METHOD_ENTER assertion to allow the entry seq-point opcode to be either INTOP_DEBUG_SEQ_POINT or INTOP_BREAKPOINT (when patched by the debugger).
Show a summary per file
File Description
src/coreclr/vm/interpexec.cpp Allow INTOP_DEBUG_METHOD_ENTER’s target opcode to be a debugger-patched breakpoint as well as the original debug seq-point.
src/coreclr/debug/ee/controller.cpp Count all MethodEnter-enabled controllers (even if not firing on the current thread) so the g_cTotalMethodEnter consistency assert holds.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@kotlarmilos
kotlarmilos requested review from noahfalk and tommcdon May 4, 2026 14:31
@kotlarmilos kotlarmilos added this to the 11.0.0 milestone May 4, 2026
@kotlarmilos kotlarmilos changed the title [interp] Fix debugger MethodEnter counter and INTOP_DEBUG_METHOD_ENTER assert [clr-interp] Fix debugger MethodEnter counter and INTOP_DEBUG_METHOD_ENTER assert May 4, 2026
Comment thread src/coreclr/debug/ee/controller.cpp
@kotlarmilos
kotlarmilos merged commit 6820c80 into dotnet:main May 12, 2026
110 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants