Skip to content

Reset frameNeedsTailcallUpdate when we don't call interp code#126475

Open
BrzVlad wants to merge 1 commit intodotnet:mainfrom
BrzVlad:fix-clrinterp-tailcall
Open

Reset frameNeedsTailcallUpdate when we don't call interp code#126475
BrzVlad wants to merge 1 commit intodotnet:mainfrom
BrzVlad:fix-clrinterp-tailcall

Conversation

@BrzVlad
Copy link
Copy Markdown
Member

@BrzVlad BrzVlad commented Apr 2, 2026

We expect that frameNeedsTailcallUpdate has a false default value. When we encounter a call flagged as tail, we set this variable to true and then proceed with the rest of the call. Once we setup the frame for the tailcall we reset this variable. The problem is that some code paths for the call could end up invoking compiled code. In this case we failed to clear the tailcall flag which means that, after returning from compiled code, if we would encounter a calling opcode that doesn't reset frameNeedsTailcallUpdate (for example INTOP_NEWOBJ), we would incorrectly proceed with a tailcall.

Fixes Runtime_72845 in DOTNET_InterpMode=1

Regressed after #123225

We expect that frameNeedsTailcallUpdate has a false default value. When we encounter a call flagged as tail, we set this variable to true and then proceed with the rest of the call. Once we setup the frame for the tailcall we reset this variable. The problem is that some code paths for the call could end up invoking compiled code. In this case we failed to clear the tailcall flag which means that, after returning from compiled code, if we would encounter a calling opcode that doesn't reset frameNeedsTailcallUpdate (for example INTOP_NEWOBJ), we would incorrectly proceed with a tailcall.

Fixes Runtime_72845 in DOTNET_InterpMode=1
@BrzVlad BrzVlad requested a review from janvorli as a code owner April 2, 2026 15:57
Copilot AI review requested due to automatic review settings April 2, 2026 15:57
@BrzVlad BrzVlad requested a review from kg as a code owner April 2, 2026 15:57
@BrzVlad BrzVlad requested a review from radekdoulik April 2, 2026 15:57
@BrzVlad
Copy link
Copy Markdown
Member Author

BrzVlad commented Apr 2, 2026

FYI @kotlarmilos

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
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

Fixes an interpreter tailcall state bug where frameNeedsTailcallUpdate could remain set after invoking compiled/unmanaged code, causing subsequent non-tail opcodes (e.g., INTOP_NEWOBJ) to incorrectly perform tailcall frame updates.

Changes:

  • Clear frameNeedsTailcallUpdate before invoking unmanaged calli paths (P/Invoke).
  • Clear frameNeedsTailcallUpdate before invoking compiled managed calli via InvokeCalliStub.
  • Clear frameNeedsTailcallUpdate before invoking compiled delegate calls and compiled managed method fallback paths.

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