Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Sep 2, 2025

Backport of #119206 to release/10.0

/cc @AndyAyersMS

Customer Impact

  • Customer reported
  • Found internally

Found by @omajid

Regression

  • Yes
  • No

The compiler was executing 1ULL << x for x > 63 as part of a chain of allocation heuristics. This shift is undefined behavior, and when the JIT was built with GCC and running on AVX-512, the heuristic unexpectedly started failing. The next heuristic up was not prepared for this and caused and AV.

The bug was introduced when we extended LSRA to support in #113988; this created more than 64 allocatable registers on xarch.

Testing

Verified locally that source builds passed; @omajid also verified the fix worked.

Risk

Low. No diffs. There was an alternate code available that can handle more than 64 registers which we already using for ARM64; now we use it for all ISAs.

During the second stage bootstrap build VMR on an AVX-512 capable machine,
we end up in `try_SPILL_COST` looking at a K-reg spill candidate without an
assigned interval,  and crash.

This happens because the preceding heuristic `try_REG_ORDER` fails to find
a register when it should, because mask register numbers are greater than 63
and we shift 1ULL by this amount to build a mask, which is undefined behavior.

The fix is to always look up the mask via table fetch, which is set up to handle
mask register numbers properly.

Fixes the crash seen in #119070.
@AndyAyersMS
Copy link
Member

@dotnet/jit-contrib PTAL
cc @JulieLeeMSFT @jeffschwMSFT

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

approved. please get a code review. we can merge when ready

@jeffschwMSFT jeffschwMSFT added Servicing-approved Approved for servicing release area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Sep 2, 2025
@jeffschwMSFT jeffschwMSFT added this to the 10.0.0 milestone Sep 2, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jeffschwMSFT jeffschwMSFT merged commit f0e957b into release/10.0 Sep 3, 2025
102 of 103 checks passed
@jkotas jkotas deleted the backport/pr-119206-to-release/10.0 branch September 8, 2025 17:33
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants