Skip to content

[release/11.0] JIT: expand all stack array allocations in a statement - #138558

Open
DavidObando wants to merge 2 commits into
dotnet:release/11.0from
DavidObando:backport/133531-release-11.0
Open

DavidObando wants to merge 2 commits into
dotnet:release/11.0from
DavidObando:backport/133531-release-11.0

Conversation

@DavidObando

Copy link
Copy Markdown
Member

Fixes Issue #138487

main PR #133531

Description

Backports #133531 (ef97eb54da2) to release/11.0.

Compiler::fgExpandStackArrayAllocations() previously broke out of its statement loop after expanding the first stack-allocated array NEWARR helper call in a statement. Because gtSplitTree only moves subtrees evaluated before the split point into earlier statements, any remaining stack-allocated NEWARR helper calls in the same statement (e.g., merged there by forward substitution) were left unexpanded with a 0-segment WellKnownArg::StackArrayLocal argument, causing an assert in Checked/Debug builds and an AV/SIGSEGV in Lowering::LowerArg / ABIPassingSegment::GetStackOffset() in Release builds.

This fix keeps rescanning the statement until all stack-allocated array helper calls in it have been expanded, and includes the Runtime_133523 regression test from the main PR.

Customer Impact

Deterministic process crash (SIGSEGV / 0xC0000005) during FullOpts JIT compilation on .NET 11.0.0 whenever forward substitution places two or more stack-allocated array allocations in the same statement (for example, 0 == c.x && new int[0] != new int[0] or first[second[index]]). The only release workaround is globally disabling object stack allocation (DOTNET_JitObjectStackAllocation=0).

Regression

Yes. Regressed in .NET 11.0.0 relative to .NET 10.

Testing

Built the Release JIT on osx-arm64 from this branch:

./build.sh clr.jit -rc Release

Result: Build succeeded. 0 Warning(s), 0 Error(s).

Verified against a copy of the installed .NET 11.0.0 (osx-arm64) runtime using a test harness containing both the repro from #138487 (0 == c.x && new int[0] != new int[0]) and the TwoArrays / ThreeArrays cases from Runtime_133523.cs:

  • Stock .NET 11.0.0 libclrjit.dylib: Segmentation fault: 11 (exit code 139).
  • Patched release/11.0 Release libclrjit.dylib: Check=True, TwoArrays=0, ThreeArrays=42 (exit code 0).

Full src/tests suite was not run locally (relying on CI matrix).

Risk

Very low. Small, localized loop change in Compiler::fgExpandStackArrayAllocations() that only affects statements containing multiple stack-allocated array helper calls (which previously always asserted/crashed). Clean cherry-pick of #133531, which has been baking in main since September 2026 with zero SPMI asm diffs.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

Resolves #138487

Note

This pull request was authored and submitted with the assistance of GitHub Copilot.

@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.

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

2 participants