Skip to content

JIT: initialize emitCurIG at declaration - #130186

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:andyayersms/fix-riscv-emitCurIG-init
Jul 3, 2026
Merged

JIT: initialize emitCurIG at declaration#130186
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:andyayersms/fix-riscv-emitCurIG-init

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

The RISC-V emitter has cost-estimation calls into emitLoadImmediate from gtSetEvalOrder that hit the new emitGeneratingPrologOrFuncletProlog check before codegen runs emitter::Init(), reading a poisoned emitCurIG and crashing (SIGSEGV in emitIGisInProlog(ig=0xdddddddddddddddd)).

Fixes#130145.

Verified locally by reproducing the CI failure with an x64-host RISC-V cross-JIT on ilc @ilc.ilc.rsp: prior to this change, exits 139 with a coredump whose stack is emitIGisInProlog(0xdddd...) <- emitGeneratingPrologOrFuncletProlog <- emitLoadImmediate<false> <- gtSetEvalOrder <- fgFindOperOrder <- compCompile while JITing System.DateTimeOffset:ToString(). With this change, ilc produces the RISC-V ilc.o and exits 0.

Note

AI-assisted PR created via GitHub Copilot CLI.

The RISC-V emitter has cost-estimation calls into emitLoadImmediate from
gtSetEvalOrder that hit the new emitGeneratingProlog check before codegen
runs emitter::Init(), reading a poisoned emitCurIG and crashing.
Fixesdotnet#130145.
CopilotAI review requested due to automatic review settings July 3, 2026 15:48
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 3, 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.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the JIT emitter’s current instruction group pointer (emitCurIG) default-initialize to nullptr so that helper queries like emitGeneratingPrologOrFuncletProlog() behave safely before emitter::Init() runs.

Changes:

  • Initialize emitter::emitCurIG at declaration (= nullptr) to avoid reading an uninitialized/poisoned pointer prior to Init().
  • Ensures early-phase callers that consult prolog/funclet state (via emitGeneratingPrologOrFuncletProlog()) return false instead of dereferencing garbage.

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

@dotnet/jit-contrib PTAL -- tiny change

@am11am11 added the arch-riscv Related to the RISC-V architecture label Jul 3, 2026
@AndyAyersMS
AndyAyersMS merged commit 360e032 into dotnet:mainJul 3, 2026
144 of 147 checks passed
@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview7 milestone Jul 4, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
The RISC-V emitter has cost-estimation calls into `emitLoadImmediate`
from `gtSetEvalOrder` that hit the new
`emitGeneratingPrologOrFuncletProlog` check before codegen runs
`emitter::Init()`, reading a poisoned `emitCurIG` and crashing (SIGSEGV
in `emitIGisInProlog(ig=0xdddddddddddddddd)`).
Fixes#130145.
Verified locally by reproducing the CI failure with an x64-host RISC-V
cross-JIT on `ilc @ilc.ilc.rsp`: prior to this change, exits 139 with a
coredump whose stack is `emitIGisInProlog(0xdddd...) <-
emitGeneratingPrologOrFuncletProlog <- emitLoadImmediate<false> <-
gtSetEvalOrder <- fgFindOperOrder <- compCompile` while JITing
`System.DateTimeOffset:ToString()`. With this change, `ilc` produces the
RISC-V `ilc.o` and exits 0.
> [!NOTE]
> AI-assisted PR created via GitHub Copilot CLI.
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Aug 4, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-riscvRelated to the RISC-V architecturearea-CodeGen-coreclrCLR 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.

ILC failing with exit code 139 for risc-v build

4 participants

@AndyAyersMS@tannergooding@am11