Skip to content

[release/11.0] JIT: Treat tailcalled delegate receivers as escaping - #138553

Open
EgorBo wants to merge 2 commits into
dotnet:release/11.0from
EgorBo:backport-136408-release-11.0
Open

EgorBo wants to merge 2 commits into
dotnet:release/11.0from
EgorBo:backport-136408-release-11.0

Conversation

@EgorBo

@EgorBo EgorBo commented Nov 30, 2026

Copy link
Copy Markdown
Member

Fixes Issue #136373

main PR #136408

Description

Backport of #136408 to release/11.0. Object stack allocation could stack-allocate a delegate whose Invoke is an explicit tail call. When that tail call goes through the runtime's tailcall helpers, the JIT passes the wrong object as the delegate. The fix treats the receivers of tail-prefixed delegate invokes as escaping.

Customer Impact

  • Customer reported
  • Found internally

Uncatchable AV in F# Release builds (tail calls are on by default) when a delegate is invoked in tail position. The only workaround is DOTNET_JitObjectStackAllocation=0. Backport requested in #138547.

Regression

  • Yes
  • No

Introduced in .NET 10 by delegate stack allocation (#115172). Works on .NET 9.

Testing

Test is backported.

Risk

Low. Only makes escape analysis more conservative for explicit tail calls, no diffs in main.

Note

PR description generated with GitHub Copilot.

EgorBo and others added 2 commits November 30, 2026 23:35
<!-- -->

Fixes dotnet#136373.

Treat delegate receivers of explicit tail calls as escaping. Tailcall
helpers require the original delegate and can use it after the caller's
frame returns, so stack allocation is unsafe.

Adds a small F# regression test that tailcalls a freshly created
delegate with enough arguments to require the helpers.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7bb954bf-2cce-4297-acb5-e4f5e2cb32b2
(cherry picked from commit a01cb86)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8c6b9802-8643-479e-bbb4-f4e04e60fc0a
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 30, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@EgorBo
EgorBo requested a review from adamperlin November 30, 2026 22:49

This branch has not been deployed

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

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants