Skip to content

A JIT bug in IV or RBO #130189

Closed
Closed

Description

@EgorBo

Repro:

using System.Runtime.CompilerServices;

sealed class S
{
    ushort[] d = [0,0,1,65535,1,0,1,65535,65535];
    int[] a = [0, 4];
    int i;

    bool Next(out int p)
    {
        bool r;
        if (r = i < a.Length)
            p = a[i++];
        else
            p = -1;
        return r;
    }

    [MethodImpl(MethodImplOptions.NoInlining | 
        MethodImplOptions.AggressiveOptimization)]
    internal long Sum()
    {
        i = 0;
        long s = 0;
        int x, p;
        while (Next(out p))
        {
            while ((x = d[p]) != 65535)
            {
                s += x;
                p++;
            }
        }
        return s;
    }

    static void Main()
    {
        if (new S().Sum() != 3)
            throw new InvalidOperationException();
    }
}

Actual:

InvalidOperationException is thrown

Expected:

no exception is thrown

Presumably reproduces on .NET 10.0 and main at least on win-x64

Activity

  1. added
    untriaged
    on Jul 3, 2026
  2. added
    area-CodeGen-coreclr
    on Jul 3, 2026
  3. added this to the 11.0.0 milestone on Jul 3, 2026
  4. self-assigned this
    on Jul 3, 2026
  5. removed
    untriaged
    on Jul 3, 2026
  6. dotnet-policy-service commented on Jul 3, 2026

    @dotnet-policy-service
    Contributor

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

  7. added a commit that references this issue on Jul 7, 2026
    5f44651
  8. added a commit that references this issue on Jul 15, 2026
    394b86e
  9. locked and limited conversation to collaborators on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions