Uh oh!
There was an error while loading. Please reload this page.
JIT: Mark GT_LCLHEAP with GTF_CALL and GTF_GLOB_REF - #132536
Conversation
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
a5d0f4c to
75fe03bCompareIf-conversion turned a conditional localloc into an unconditional one feeding a SELECT, since GT_LCLHEAP no longer carries any effect flags. The guarding branch is what bounds the allocation size (as the interop string marshalling stubs do), so the speculated localloc overflowed the stack. Fixesdotnet#132243 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
75fe03b to
8f1ac90CompareThere was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes a JIT miscompile where conditional localloc (GT_LCLHEAP) could be speculated across its guarding check due to missing effect flags, potentially causing stack overflow in guarded allocation patterns.
Changes:
- Mark
GT_LCLHEAPwithGTF_ORDER_SIDEEFFduring import to preserve ordering below dominating bounds checks. - Teach
GenTree::OperSupportsOrderingSideEffectthatGT_LCLHEAPsupports ordering side effects. - Add a regression test validating conditional
stackallocis not speculated into an unconditional allocation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/tests/JIT/Regression/Regression_ro_2.csproj | Registers the new regression test source file in the test project. |
| src/tests/JIT/Regression/JitBlue/Runtime_132243/Runtime_132243.cs | Adds a repro/regression validating conditional stackalloc remains guarded. |
| src/coreclr/jit/importer.cpp | Applies GTF_ORDER_SIDEEFF to GT_LCLHEAP to prevent unsafe reordering/speculation. |
| src/coreclr/jit/gentree.cpp | Allows GT_LCLHEAP to participate in ordering-side-effect handling. |
jakobbotsch
commented
Aug 19, 2026
I suspect the node should instead get |
GTF_ORDER_SIDEEFF only interferes with other GTF_ORDER_SIDEEFF nodes, so it does not prevent the localloc from being reordered with, or predicated on, side-effect-free code. Mark it as a call and global reference, as GT_KEEPALIVE does, and register the flags as required so they are not scrubbed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EgorBo
commented
Aug 20, 2026
Thanks, switched to Also added SPMI replay is clean; diffs are small and mixed (benchmarks.run +11, aspnet2 +141, libraries.pmi -71, realworld -8 bytes; linux-arm64 aspnet2 +72). |
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
EgorBo
commented
Aug 21, 2026
/ba-g deadletter |
Uh oh!
There was an error while loading. Please reload this page.
Fixes#132243.
GT_LCLHEAPstopped carrying any effect flags in #125362, so if-conversion started converting the conditionallocallocin the interop string marshalling stubs into an unconditional one feeding aSELECT:The guarding branch is what bounds the allocation size, so the
locallocmust not be reordered with, or made to execute under a different condition than, the surrounding code. This marksGT_LCLHEAPwithGTF_CALL | GTF_GLOB_REF, the same wayGT_KEEPALIVEis handled, and adds it toOperRequiresCallFlag/OperRequiresGlobRefFlagso the flags are not scrubbed bygtUpdateNodeOperSideEffects.Repros in pure managed code too:
Local diffs: benchmarks.run +11, aspnet2 +141, libraries.pmi -71, realworld -8 bytes; linux-arm64 aspnet2 +72 bytes. SPMI replay clean.