Skip to content

JIT: mark GC safe point after stelem.ref call transformation - #134973

Merged
EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:jit-fix-134894
Oct 1, 2026
Merged

EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:jit-fix-134894

Conversation

@EgorBo

@EgorBo EgorBo commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

fgMorphCall marked the block as a GC safe point while the stelem.ref call was still a user call, before it was replaced by a plain store (or converted back to a helper call). The stale flag could leave a call-free loop without GC polls.Fixes #134894

Diffs

fgMorphCall marked the block as a GC safe point while the stelem.ref call was
still a user call, before it was replaced by a plain store (or converted back to
a helper call). The stale flag could leave a call-free loop without GC polls.

Fixes dotnet#134894

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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 Sep 30, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

@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 jakobbotsch September 30, 2026 20:43
@EgorBo

EgorBo commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

PTAL @jakobbotsch @dotnet/jit-contrib no diffs (some methods switched to fully-interruptible mode)

@EgorBo
EgorBo merged commit 12955c8 into dotnet:main Oct 1, 2026
145 of 147 checks passed
@EgorBo
EgorBo deleted the jit-fix-134894 branch October 1, 2026 14:49
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 2, 2026
EgorBo added a commit that referenced this pull request Oct 8, 2026
…135415)

<!-- -->
Fixes #135390
Fixes #135407
Contributes to #134837

Recent changes made more methods fully interruptible (e.g.
#134973), which exposed a few
pre-existing x86 GC tracking issues:

- **`emitxarch.cpp`**: `emitOutputSV`/`emitOutputCV` didn't kill the GC
liveness of the destination register for several formats (`*_SRD_CNS`,
`*_SRD_RRD`, `*_MRD_CNS`, etc.), e.g. `rorx edi, dword ptr [ebp+0x08],
5` kept `edi` reported as a live GC ref. The address-mode path
(`emitOutputAM`) already handled these.
- **`codegenxarch.cpp`**: `genCodeForSwap` only passed `EA_GCREF` to the
emitter when exactly one side was a GC type, so a ref<->byref `xchg`
didn't swap the emitter's GC tracking (the
`InvokeDirectByRefWithFewArgs` listing in #134837). Hit by the
`DevDiv_*` tests that use `JitStressRegs=0x200`.
- **`threadsuspend.cpp`**: on x86 the `InlinedCallFrame` stays linked
for the whole method and the stack walker reports it before the
containing method. `SWCB_GetExecutionState` therefore treated a thread
spinning in such a method as "not in JIT code" and never redirected it,
hanging GC suspension (`Runtime_134894` under GCStress). Skip the
inactive `InlinedCallFrame`. Also fixed the stale "non-x86" comments in
`stackwalk.cpp`.

Not fixed here: an intermittent hole in the `JitNoStructPromotion=1`
tests (e.g. `Runtime_71831`). `CORINFO_HELP_BULK_WRITEBARRIER_SMALL` is
treated as a no-GC helper, but its first call can go through the
prestub, which can GC.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Copilot-Session: a10e9000-66df-46e3-94d8-88019bcaf192
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.

JIT: (bug) loop left partially interruptible after morph removes the stelem.ref call (GC suspension hang)

2 participants