Skip to content

[RyuJIT] Bad CodeGen with Dynamic PGO + JitStressRegs=2 on .NET 8 (x64) #122057

@lhr1101

Description

@lhr1101

Description

I discovered a JIT CodeGen bug using automated differential fuzzing. The program produces different outputs (checksums) depending on whether Dynamic PGO and JitStressRegs are enabled.

Reproduction Steps

  1. Create a new .NET 8 console app: dotnet new console -n ReproBug
  2. Important: Modify ReproBug.csproj to allow unsafe blocks (required for the checksum function):
    <PropertyGroup>
      <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    </PropertyGroup>
    

Expected behavior

set DOTNET_TieredCompilation=0
set DOTNET_TieredPGO=0
set COMPlus_JitStressRegs=0
dotnet run -c Release

The checksum should be 49B5F8F053C8A9CC regardless of PGO/Stress settings.

Actual behavior

set DOTNET_TieredCompilation=1
set DOTNET_TieredPGO=1
set COMPlus_JitStressRegs=2
set DOTNET_EnableAVX2=0
dotnet run -c Release

When Dynamic PGO is enabled alongside JitStressRegs=2 (and AVX2 disabled), the checksum changes to AB1CED180818F52B.

Regression?

Reproduces on: .NET 8.0 (Release Build)
Does NOT reproduce on: .NET 10.0 Preview (The behavior seems consistent on .NET 10, suggesting it might be fixed or behavior changed in main branch).

Known Workarounds

No response

Configuration

No response

Other information

The reproduction code includes:
A PGO warmup loop (40 iterations).
A ResetStatics method to ensure memory is clean between iterations.
Interfaces and Checksum logic required to run the generated code.

ReproTest.zip

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions