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

Assertion failed 'fgReachable(begBlk, endBlk)' during 'Update flow graph opt pass' #64764

Closed
kunalspathak opened this issue Feb 3, 2022 · 4 comments · Fixed by #72134
Closed
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

// Found by Antigen
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
public class TestClass
{
    public struct S1
    {
    }
    public struct S2
    {
        public ulong ulong_1;
    }
    static bool s_bool_2 = false;
    static byte s_byte_3 = 5;
    static int s_int_8 = 2;
    static S1 s_s1_16 = new S1();
    static S2 s_s2_17 = new S2();
    int int_24 = -2;
    sbyte sbyte_26 = 10;
    S2 s2_33 = new S2();
    static int s_loopInvariant = 4;
    public bool LeafMethod0()
    {
        unchecked
        {
            return 15>=4&& s_bool_2;
        }
    }
    [MethodImpl(MethodImplOptions.NoInlining)]
    public int LeafMethod6()
    {
        unchecked
        {
            return s_int_8 >>= int_24;
        }
    }
    public uint Method1(out S2 p_s2_34, out S1 p_s1_35, S1 p_s1_36, out byte p_byte_37, S1 p_s1_38, ref ulong p_ulong_39)
    {
        unchecked
        {
            bool bool_40 = false;
            char char_42 = 'J';
            sbyte sbyte_48 = 1;
            p_s2_34 = s2_33;
            p_s1_35 = s_s1_16;
            p_byte_37 = s_byte_3 = s_byte_3 <<= 15^4;
            int __loopvar43 = 15-4, __loopSecondaryVar43_0 = s_loopInvariant;
            for (; s_int_8 < 15%4; s_int_8++)
            {
                if ((sbyte_26 += 15-4)< sbyte_48)
                {
                    switch (char_42 = char_42 = char_42)
                    {
                        case 'K':
                        {
                            break;
                        }
                        case 'I':
                        {
                            if (LeafMethod0())
                            {
                                int __loopvar9 = s_loopInvariant;
                                while (bool_40)
                                {
                                    if (bool_40 = s_bool_2 = (int_24 %= 15+4)> (int_24 &= LeafMethod6()))
                                    {
                                    }
                                    else
                                    {
                                    }
                                    try
                                    {
                                        int __loopvar8 = s_loopInvariant, __loopSecondaryVar8_0 = 15+4;
                                    }
                                    catch (System.TimeZoneNotFoundException)
                                    {
                                    }
                                }
                            }
                            else
                            {
                            }
                            break;
                        }
                        case 'A':
                        {
                            break;
                        }
                        case 'C':
                        {
                            break;
                        }
                        case 'M':
                        {
                            break;
                        }
                        case '2':
                        {
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                }
                else
                {
                }
            }
            return 15|4;
        }
    }
    public void Method0()
    {
        unchecked
        {
            uint uint_99 = 5;
            S1 s1_101 = new S1();
            uint_99 = Method1(out s_s2_17, out s1_101, s_s1_16, out s_byte_3, s_s1_16, ref s2_33.ulong_1);
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}
/*
Got output diff:
--------- Baseline ---------  

Environment:



--------- Test ---------  

Environment:

set COMPlus_TieredCompilation=0
set COMPlus_JitDoCopyProp=1
set COMPlus_EnableSSE41=1
set COMPlus_JitStress=2
set COMPlus_GCStress=0xC
set COMPlus_AltJitName=clrjit_win_x86_x64.dll
set COMPlus_AltJit=Method1

Assert failure(PID 198288 [0x00030690], Thread: 232112 [0x38ab0]): Assertion failed 'fgReachable(begBlk, endBlk)' in 'TestClass:Method1(byref,byref,S1,byref,S1,byref):int:this' during 'Update flow graph opt pass' (IL size 270)
    File: D:\git\dotnet-runtime\src\coreclr\jit\optimizer.cpp Line: 167
    Image: d:\git\dotnet-runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
@dotnet-issue-labeler dotnet-issue-labeler bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Feb 3, 2022
@kunalspathak kunalspathak added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Feb 3, 2022
@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib

@ghost
Copy link

ghost commented Feb 3, 2022

Tagging subscribers to this area: @JulieLeeMSFT
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 struct S2
    {
        public ulong ulong_1;
    }
    static bool s_bool_2 = false;
    static byte s_byte_3 = 5;
    static int s_int_8 = 2;
    static S1 s_s1_16 = new S1();
    static S2 s_s2_17 = new S2();
    int int_24 = -2;
    sbyte sbyte_26 = 10;
    S2 s2_33 = new S2();
    static int s_loopInvariant = 4;
    public bool LeafMethod0()
    {
        unchecked
        {
            return 15>=4&& s_bool_2;
        }
    }
    [MethodImpl(MethodImplOptions.NoInlining)]
    public int LeafMethod6()
    {
        unchecked
        {
            return s_int_8 >>= int_24;
        }
    }
    public uint Method1(out S2 p_s2_34, out S1 p_s1_35, S1 p_s1_36, out byte p_byte_37, S1 p_s1_38, ref ulong p_ulong_39)
    {
        unchecked
        {
            bool bool_40 = false;
            char char_42 = 'J';
            sbyte sbyte_48 = 1;
            p_s2_34 = s2_33;
            p_s1_35 = s_s1_16;
            p_byte_37 = s_byte_3 = s_byte_3 <<= 15^4;
            int __loopvar43 = 15-4, __loopSecondaryVar43_0 = s_loopInvariant;
            for (; s_int_8 < 15%4; s_int_8++)
            {
                if ((sbyte_26 += 15-4)< sbyte_48)
                {
                    switch (char_42 = char_42 = char_42)
                    {
                        case 'K':
                        {
                            break;
                        }
                        case 'I':
                        {
                            if (LeafMethod0())
                            {
                                int __loopvar9 = s_loopInvariant;
                                while (bool_40)
                                {
                                    if (bool_40 = s_bool_2 = (int_24 %= 15+4)> (int_24 &= LeafMethod6()))
                                    {
                                    }
                                    else
                                    {
                                    }
                                    try
                                    {
                                        int __loopvar8 = s_loopInvariant, __loopSecondaryVar8_0 = 15+4;
                                    }
                                    catch (System.TimeZoneNotFoundException)
                                    {
                                    }
                                }
                            }
                            else
                            {
                            }
                            break;
                        }
                        case 'A':
                        {
                            break;
                        }
                        case 'C':
                        {
                            break;
                        }
                        case 'M':
                        {
                            break;
                        }
                        case '2':
                        {
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                }
                else
                {
                }
            }
            return 15|4;
        }
    }
    public void Method0()
    {
        unchecked
        {
            uint uint_99 = 5;
            S1 s1_101 = new S1();
            uint_99 = Method1(out s_s2_17, out s1_101, s_s1_16, out s_byte_3, s_s1_16, ref s2_33.ulong_1);
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}
/*
Got output diff:
--------- Baseline ---------  

Environment:



--------- Test ---------  

Environment:

set COMPlus_TieredCompilation=0
set COMPlus_JitDoCopyProp=1
set COMPlus_EnableSSE41=1
set COMPlus_JitStress=2
set COMPlus_GCStress=0xC
set COMPlus_AltJitName=clrjit_win_x86_x64.dll
set COMPlus_AltJit=Method1

Assert failure(PID 198288 [0x00030690], Thread: 232112 [0x38ab0]): Assertion failed 'fgReachable(begBlk, endBlk)' in 'TestClass:Method1(byref,byref,S1,byref,S1,byref):int:this' during 'Update flow graph opt pass' (IL size 270)
    File: D:\git\dotnet-runtime\src\coreclr\jit\optimizer.cpp Line: 167
    Image: d:\git\dotnet-runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
Author: kunalspathak
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged

Milestone: -

@BruceForstall BruceForstall added this to the 7.0.0 milestone Feb 9, 2022
@BruceForstall BruceForstall self-assigned this Feb 9, 2022
@BruceForstall BruceForstall removed the untriaged New issue has not been triaged by the area owner label Feb 9, 2022
@BruceForstall
Copy link
Member

BruceForstall commented Feb 11, 2022

This repros with an x86 VM/JIT with just:

set COMPlus_TieredCompilation=0
set COMPlus_JitStressModeNames=STRESS_BB_PROFILE

@kunalspathak COMPlus_JitDoCopyProp=1 is the default; why bother setting it? Same for COMPlus_EnableSSE41=1.

@kunalspathak
Copy link
Member Author

@kunalspathak COMPlus_JitDoCopyProp=1 is the default; why bother setting it? Same for COMPlus_EnableSSE41=1.

We have on and off configs for most of the switches and then we pick random value among them. So some switches might be redundant.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 13, 2022
BruceForstall added a commit to BruceForstall/runtime that referenced this issue Jul 15, 2022
Due to very odd, stress-induced flow graph, on x86, the fall-through
predecessor block to an empty (but not unreachable) block was a
"catch" handler that was not reachable from the block's target (since
"catch" blocks don't have predecessors).

However, the code in fgRemoveBlock that was calling optScaleLoopBlocks
didn't make any sense, and removing it causes no diffs. So get rid of it.

Fixes dotnet#64764
BruceForstall added a commit that referenced this issue Jul 15, 2022
Due to very odd, stress-induced flow graph, on x86, the fall-through
predecessor block to an empty (but not unreachable) block was a
"catch" handler that was not reachable from the block's target (since
"catch" blocks don't have predecessors).

However, the code in fgRemoveBlock that was calling optScaleLoopBlocks
didn't make any sense, and removing it causes no diffs. So get rid of it.

Fixes #64764
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 14, 2022
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

Successfully merging a pull request may close this issue.

2 participants