Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JitOptRepeat] Assertion failed 'limit->OperGet() == GT_ARR_LENGTH' during 'Optimize Valnum CSEs' #74785

Closed
kunalspathak opened this issue Aug 29, 2022 · 7 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@kunalspathak
Copy link
Member

kunalspathak commented Aug 29, 2022

// Found by Antigen

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
public class TestClass
{
    public struct S1
    {
        public byte byte_0;
    }
    public struct S2
    {
    }
    static decimal s_decimal_7 = 5.0625m;
    static double s_double_8 = 1;
    static uint s_uint_16 = 5;
    static S1 s_s1_18 = new S1();
    static S2 s_s2_19 = new S2();
    bool bool_20 = true;
    uint uint_32 = 5;
    ulong ulong_33 = 0;
    S1 s1_34 = new S1();
    S2 s2_35 = new S2();
    static int s_loopInvariant = 2;
    public decimal Method9(ref S2 p_s2_262)
    {
        unchecked
        {
            return 15%4;
        }
    }
    public S2 Method34(S1 p_s1_892, ref S2 p_s2_893, ref S2 p_s2_894, ref byte p_byte_895, out S1 p_s1_896, S2 p_s2_897)
    {
        unchecked
        {
            for (int __loopvar2 = 15-4; 15!=4;)
            {
                do
                {
                    for (;;)
                    {
                        s_decimal_7 *= Method9(ref s_s2_19);
                    }
                }
                while (15!=4);
            }
            return s_s2_19;
        }
    }
    public void Method0()
    {
        unchecked
        {
            S2 s2_2627 = new S2();
            s_s2_19 = Method34(s_s1_18, ref s2_2627, ref s2_35, ref s1_34.byte_0, out s_s1_18, s2_35);
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}
/*
Environment:

set COMPlus_AltJitName=clrjit_unix_x64_x64.dll
set COMPlus_AltJit=GetContainingSectionIndex
set COMPlus_JitOptRepeat=*

Unhandled exception. 
Assert failure(PID 68200 [0x00010a68], Thread: 13360 [0x3430]): Assertion failed 'limit->OperGet() == GT_ARR_LENGTH' in 'System.Reflection.PortableExecutable.PEHeaders:GetContainingSectionIndex(int):int:this' during 'Optimize Valnum CSEs' (IL size 93; hash 0x7476b29f; FullOpts)
    File: D:\git\dotnet-runtime\src\coreclr\jit\compiler.hpp Line: 3485
    Image: d:\git\dotnet-runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/

category:correctness
theme:value-numbering
skill-level:intermediate
cost:small
impact:small

@kunalspathak kunalspathak added this to the 8.0.0 milestone Aug 29, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 29, 2022
@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib

@ghost
Copy link

ghost commented Aug 29, 2022

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

Issue Details
// Found by Antigen

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
public class TestClass
{
    public struct S1
    {
        public byte byte_0;
    }
    public struct S2
    {
    }
    static decimal s_decimal_7 = 5.0625m;
    static double s_double_8 = 1;
    static uint s_uint_16 = 5;
    static S1 s_s1_18 = new S1();
    static S2 s_s2_19 = new S2();
    bool bool_20 = true;
    uint uint_32 = 5;
    ulong ulong_33 = 0;
    S1 s1_34 = new S1();
    S2 s2_35 = new S2();
    static int s_loopInvariant = 2;
    public decimal Method9(ref S2 p_s2_262)
    {
        unchecked
        {
            return 15%4;
        }
    }
    public S2 Method34(S1 p_s1_892, ref S2 p_s2_893, ref S2 p_s2_894, ref byte p_byte_895, out S1 p_s1_896, S2 p_s2_897)
    {
        unchecked
        {
            for (int __loopvar2 = 15-4; 15!=4;)
            {
                do
                {
                    for (;;)
                    {
                        s_decimal_7 *= Method9(ref s_s2_19);
                    }
                }
                while (15!=4);
            }
            return s_s2_19;
        }
    }
    public void Method0()
    {
        unchecked
        {
            S2 s2_2627 = new S2();
            s_s2_19 = Method34(s_s1_18, ref s2_2627, ref s2_35, ref s1_34.byte_0, out s_s1_18, s2_35);
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}
/*
Environment:

set COMPlus_AltJitName=clrjit_unix_x64_x64.dll
set COMPlus_AltJit=GetContainingSectionIndex
set COMPlus_JitOptRepeat=*

Unhandled exception. 
Assert failure(PID 68200 [0x00010a68], Thread: 13360 [0x3430]): Assertion failed 'limit->OperGet() == GT_ARR_LENGTH' in 'System.Reflection.PortableExecutable.PEHeaders:GetContainingSectionIndex(int):int:this' during 'Optimize Valnum CSEs' (IL size 93; hash 0x7476b29f; FullOpts)
    File: D:\git\dotnet-runtime\src\coreclr\jit\compiler.hpp Line: 3485
    Image: d:\git\dotnet-runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
Author: kunalspathak
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: 8.0.0

@EgorBo
Copy link
Member

EgorBo commented Aug 29, 2022

set COMPlus_JitOptRepeat=*

seems to be broken in many ways, I tried to enable it for NativeAOT (to repeat ops at least twice) and it failed in many methods with different asserts (I am not saying it should not be fixed though)

@kunalspathak
Copy link
Member Author

True. I am not sure if I should disable this flag from Antigen until we fix these issues.

@jakobbotsch
Copy link
Member

Will move this out of 8.0 given this is a JitOptRepeat=* issue.

@jakobbotsch jakobbotsch modified the milestones: 8.0.0, Future Mar 16, 2023
@jakobbotsch jakobbotsch changed the title Assertion failed 'limit->OperGet() == GT_ARR_LENGTH' during 'Optimize Valnum CSEs' [JitOptRepeat] Assertion failed 'limit->OperGet() == GT_ARR_LENGTH' during 'Optimize Valnum CSEs' Mar 16, 2023
@BruceForstall
Copy link
Member

I'm going to take this one.

@BruceForstall
Copy link
Member

This doesn't repro for me. Possibly fixed by #94250 and related.

@github-actions github-actions bot locked and limited conversation to collaborators May 6, 2024
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
Projects
None yet
Development

No branches or pull requests

4 participants