Skip to content

Assertion failed '!foundMismatch' during 'LSRA allocate' #66580

Closed

Description

@jakobbotsch

Description

The following program hits a JIT assert on arm32 when optimizing.

Reproduction Steps

// Generated by Fuzzlyn v1.5 on 2022-03-13 15:06:11
// Run on Arm Linux
// Seed: 6652345110448962334
// Reduced from 75.1 KiB to 3.2 KiB in 00:04:13
// Hits JIT assert in Release:
// Assertion failed '!foundMismatch' in 'Program:MainInner(IRuntime)' during 'LSRA allocate' (IL size 301; hash 0xade6b36b; FullOpts)
// 
//     File: /__w/1/s/src/coreclr/jit/lsra.cpp Line: 8123
// 
public struct S0
{
    public int F0;
    public uint F4;
    public byte F5;
    public S0(byte f5): this()
    {
    }
}

public class C0
{
}

public class C1
{
    public short F3;
    public S0 F4;
    public S0 F5;
}

public struct S1
{
    public sbyte F0;
    public C0 F1;
    public C1 F2;
    public C1 F3;
    public ulong F4;
    public int F5;
    public uint F6;
    public ulong F7;
    public ulong F8;
    public S1(sbyte f0, C0 f1, C1 f2, C1 f3, ulong f4, int f5, uint f6, ulong f7, ulong f8)
    {
        F0 = f0;
        F1 = f1;
        F2 = f2;
        F3 = f3;
        F4 = f4;
        F5 = f5;
        F6 = f6;
        F7 = f7;
        F8 = f8;
    }
}

public struct S2
{
    public S1 F2;
}

public struct S3
{
    public long F0;
    public uint F1;
}

public class Program
{
    public static IRuntime s_rt;
    public static C1 s_3;
    public static S2 s_4;
    public static void Main()
    {
        CollectibleALC alc = new CollectibleALC();
        System.Reflection.Assembly asm = alc.LoadFromAssemblyPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
        System.Reflection.MethodInfo mi = asm.GetType(typeof(Program).FullName).GetMethod(nameof(MainInner));
        System.Type runtimeTy = asm.GetType(typeof(Runtime).FullName);
        mi.Invoke(null, new object[]{System.Activator.CreateInstance(runtimeTy)});
    }

    public static void MainInner(IRuntime rt)
    {
        S2 vr6 = default(S2);
        if (!!!(0 <= (uint)M1(ref s_3)))
        {
            try
            {
                s_rt.WriteLine("c_149", vr6.F2.F3.F4.F5);
            }
            finally
            {
                ref int vr7 = ref s_3.F4.F0;
                for (int vr8 = 0; vr8 < -1; vr8++)
                {
                    var vr9 = s_4.F2.F3.F3;
                    var vr10 = new byte[]{0};
                    var vr11 = new S3();
                    S0[] vr12 = M8(vr9, ref s_3.F5.F4, vr10, M11(vr11));
                    s_rt.WriteLine("c_462", vr12[0].F0);
                    s_rt.WriteLine("c_467", vr12[0].F5);
                }

                var vr13 = new S1(0, new C0(), new C1(), new C1(), 0, 0, 0, 0, 0);
                var vr14 = new S1(0, new C0(), new C1(), new C1(), 0, 0, 0, 0, 0);
                vr7 = vr7;
            }
        }

        uint vr17 = s_3.F5.F4;
    }

    public static byte M1(ref C1 arg0)
    {
        for (int var0 = 0; var0 < 0; var0++)
        {
        }

        uint var3 = arg0.F5.F4;
        return 1;
    }

    public static ushort[][][] M11(S3 arg1)
    {
        return new ushort[][][]{new ushort[][]{new ushort[]{0}}};
    }

    public static S0[] M8(short arg0, ref uint arg2, byte[] arg3, ushort[][][] arg4)
    {
        return new S0[]{new S0(0)};
    }
}

public interface IRuntime
{
    void WriteLine<T>(string site, T value);
}

public class Runtime : IRuntime
{
    public void WriteLine<T>(string site, T value) => System.Console.WriteLine(value);
}

public class CollectibleALC : System.Runtime.Loader.AssemblyLoadContext
{
    public CollectibleALC(): base(true)
    {
    }
}

Expected behavior

No JIT assert hit.

Actual behavior

JIT assert is hit.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

category:correctness
theme:register-allocator

Activity

  1. ghost added
    area-CodeGen-coreclr
    on Mar 14, 2022
  2. ghost added
    untriaged
    on Mar 14, 2022
  3. added this to the 7.0.0 milestone on Mar 14, 2022
  4. removed
    untriaged
    on Mar 14, 2022
  5. kunalspathak commented on Apr 20, 2022

    @kunalspathak
    Contributor

    I am no longer able to repro this on latest main 544f720.

  6. jakobbotsch commented on May 2, 2022

    @jakobbotsch
    MemberAuthor

    New repro in https://dnceng.visualstudio.com/public/_build/results?buildId=1746386&view=ms.vss-build-web.run-extensions-tab

    // Generated by Fuzzlyn v1.5 on 2022-05-01 15:27:52
    // Run on Arm Linux
    // Seed: 16118003303842417594
    // Reduced from 655.4 KiB to 2.0 KiB in 00:17:37
    // Hits JIT assert in Release:
    // Assertion failed '!foundMismatch' in 'Program:M8(C0[])' during 'LSRA allocate' (IL size 97; hash 0x26afbe2a; FullOpts)
    // 
    //     File: /__w/1/s/src/coreclr/jit/lsra.cpp Line: 8106
    // 
    public class C0
    {
        public uint F0;
        public bool F2;
        public bool F4;
        public ushort F5;
        public uint F6;
        public int F8;
        public sbyte F9;
        public C0(uint f0, bool f2, bool f4, ushort f5, uint f6, int f8, sbyte f9)
        {
            F0 = f0;
            F2 = f2;
            F4 = f4;
            F5 = f5;
            F6 = f6;
            F8 = f8;
            F9 = f9;
        }
    }
    
    public struct S0
    {
        public C0 F3;
    }
    
    public class Program
    {
        public static S0 s_3;
        public static S0 s_7;
        public static void Main()
        {
            CollectibleALC alc = new CollectibleALC();
            System.Reflection.Assembly asm = alc.LoadFromAssemblyPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
            System.Reflection.MethodInfo mi = asm.GetType(typeof(Program).FullName).GetMethod(nameof(MainInner));
            System.Type runtimeTy = asm.GetType(typeof(Runtime).FullName);
            mi.Invoke(null, new object[]{System.Activator.CreateInstance(runtimeTy)});
        }
    
        public static void MainInner(IRuntime rt)
        {
            var vr6 = new C0[]{new C0(0, true, false, 1, 0, 1, 0)};
            M8(vr6);
        }
    
        public static void M8(C0[] arg5)
        {
            for (int var2 = 0; var2 < 1; var2++)
            {
                return;
            }
    
            for (int var7 = 0; var7 < 1; var7++)
            {
                try
                {
                    s_7.F3.F6 = 0;
                }
                finally
                {
                    ulong[] var9 = new ulong[]{1};
                    bool var11 = s_3.F3.F4;
                    for (int var12 = 0; var12 < 2; var12++)
                    {
                        arg5[0] = new C0(0, false, false, 0, 0, 0, 0);
                    }
                }
            }
        }
    }
    
    public interface IRuntime
    {
        void WriteLine<T>(string site, T value);
    }
    
    public class Runtime : IRuntime
    {
        public void WriteLine<T>(string site, T value) => System.Console.WriteLine(value);
    }
    
    public class CollectibleALC : System.Runtime.Loader.AssemblyLoadContext
    {
        public CollectibleALC(): base(true)
        {
        }
    }
  7. modified the milestones: 7.0.0, 8.0.0 on Jun 13, 2022
  8. kunalspathak commented on May 5, 2023

    @kunalspathak
    Contributor

    Don't see this reproing anymore in main. @jakobbotsch - if you see it happening, feel free to reopen with an updated example.

  9. jakobbotsch commented on May 22, 2023

    @jakobbotsch
    MemberAuthor

    Here's a new case:

    // Generated by Fuzzlyn v1.5 on 2023-05-21 15:24:19
    // Run on Arm Linux
    // Seed: 17682101241280527991
    // Reduced from 289.4 KiB to 2.2 KiB in 00:04:28
    // Hits JIT assert in Release:
    // Assertion failed '!foundMismatch' in 'Program:M99(C0):int' during 'LSRA allocate' (IL size 146; hash 0x7ac3129d; FullOpts)
    // 
    //     File: /__w/1/s/src/coreclr/jit/lsra.cpp Line: 8609
    // 
    public interface I0
    {
    }
    
    public class C0
    {
        public ulong F0;
        public sbyte F2;
        public byte F3;
        public bool F4;
        public C0(ulong f0, sbyte f2, byte f3, byte f5)
        {
            F0 = f0;
            F2 = f2;
            F3 = f3;
        }
    }
    
    public class Program
    {
        public static ushort[] s_6;
        public static I0 s_25;
        public static int[] s_30;
        public static short s_48;
        public static short s_62;
        public static sbyte[][] s_64;
        public static long[] s_65;
        public static C0 s_74;
        public static void Main()
        {
            CollectibleALC alc = new CollectibleALC();
            System.Reflection.Assembly asm = alc.LoadFromAssemblyPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
            System.Reflection.MethodInfo mi = asm.GetType(typeof(Program).FullName).GetMethod(nameof(MainInner));
            System.Type runtimeTy = asm.GetType(typeof(Runtime).FullName);
            mi.Invoke(null, new object[]{System.Activator.CreateInstance(runtimeTy)});
        }
    
        public static void MainInner(IRuntime rt)
        {
            var vr4 = new C0(0, 0, 0, 0);
            M99(vr4);
        }
    
        public static int M99(C0 argThis)
        {
            if (argThis.F4)
            {
                return s_62;
            }
    
            for (int var10 = 0; var10 < 0; var10++)
            {
                var vr0 = s_48++;
                try
                {
                    C0 vr5 = s_74;
                }
                finally
                {
                    for (int var13 = 0; var13 < 2; var13++)
                    {
                        var vr3 = new byte[]{0, 0, 0, 0, 1, 0, 0};
                        ref long vr6 = ref s_65[0];
                        I0 vr7 = s_25;
                        var vr2 = new C0((ulong)vr6, s_64[0][0], argThis.F3, argThis.F3--);
                        ushort vr9 = s_6[0];
                    }
                }
            }
    
            return s_30[0];
        }
    }
    
    public interface IRuntime
    {
        void WriteLine<T>(string site, T value);
    }
    
    public class Runtime : IRuntime
    {
        public void WriteLine<T>(string site, T value) => System.Console.WriteLine(value);
    }
    
    public class CollectibleALC : System.Runtime.Loader.AssemblyLoadContext
    {
        public CollectibleALC(): base(true)
        {
        }
    }
  10. added
    Priority:3
    on Jun 5, 2023
  11. modified the milestones: 8.0.0, 9.0.0 on Jul 30, 2023
  12. jakobbotsch commented on Aug 13, 2024

    @jakobbotsch
    MemberAuthor

    Doesn't repro with this example anymore. Will wait for a new one.

  13. locked and limited conversation to collaborators on Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Priority:3arch-arm32area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions