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.

Fixes dotnet#130145.
Copilot AI review requested due to automatic review settings July 3, 2026 15:48
@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 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.

Copilot AI 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
Member Author

@dotnet/jit-contrib PTAL -- tiny change

@am11 am11 added the arch-riscv Related to the RISC-V architecture label Jul 3, 2026
@AndyAyersMS AndyAyersMS merged commit 360e032 into dotnet:main Jul 3, 2026
144 of 147 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-riscv Related to the RISC-V architecture 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.

ILC failing with exit code 139 for risc-v build

4 participants