Repository navigation
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
75fe03b
Compare
If-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. Fixes dotnet#132243 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
75fe03b to
8f1ac90
Compare
There 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. |
|
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>
|
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.
|
/ba-g deadletter |
|
/backport to release/11.0 |
|
Started backporting to |
|
@AaronRobinsonMSFT backporting to git am output$ git cherry-pick 3ab25f0e7c1739849a32aca8b1c5a47f983b743c
Auto-merging src/coreclr/jit/gentree.cpp
Auto-merging src/coreclr/jit/importer.cpp
Auto-merging src/tests/JIT/Regression/Regression_ro_2.csproj
CONFLICT (content): Merge conflict in src/tests/JIT/Regression/Regression_ro_2.csproj
error: could not apply 3ab25f0e7c1... JIT: Mark GT_LCLHEAP with GTF_CALL and GTF_GLOB_REF (#132536)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: JIT: Mark GT_LCLHEAP with GTF_ORDER_SIDEEFF
Using index info to reconstruct a base tree...
M src/coreclr/jit/gentree.cpp
M src/coreclr/jit/importer.cpp
M src/tests/JIT/Regression/Regression_ro_2.csproj
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/jit/gentree.cpp
Auto-merging src/coreclr/jit/importer.cpp
Auto-merging src/tests/JIT/Regression/Regression_ro_2.csproj
CONFLICT (content): Merge conflict in src/tests/JIT/Regression/Regression_ro_2.csproj
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 JIT: Mark GT_LCLHEAP with GTF_ORDER_SIDEEFF
Error: The process '/usr/bin/git' failed with exit code 128 |
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.