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 '!foundDiff' during 'Linear scan register alloc' #69659

Closed
jakobbotsch opened this issue May 22, 2022 · 4 comments · Fixed by #69897
Closed

Assertion failed '!foundDiff' during 'Linear scan register alloc' #69659

jakobbotsch opened this issue May 22, 2022 · 4 comments · Fixed by #69897
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@jakobbotsch
Copy link
Member

// Generated by Fuzzlyn v1.5 on 2022-05-22 15:46:22
// Run on X64 Windows
// Seed: 6568846458402286114
// Reduced from 194.5 KiB to 0.5 KiB in 00:02:48
// Hits JIT assert in Release:
// Assertion failed '!foundDiff' in 'Program:M27(int,System.UInt64[][])' during 'Linear scan register alloc' (IL size 35; hash 0xf8af49d2; FullOpts)
// 
//     File: D:\a\_work\1\s\src\coreclr\jit\lsra.cpp Line: 2264
// 
public class Program
{
    public static ulong[] s_14;
    public static uint s_34;
    public static void Main()
    {
        var vr2 = new ulong[][]{new ulong[]{0}};
        M27(s_34, vr2);
    }

    public static void M27(uint arg4, ulong[][] arg5)
    {
        arg5[0][0] = arg5[0][0];
        for (int var7 = 0; var7 < 1; var7++)
        {
            return;
        }

        try
        {
            s_14 = arg5[0];
        }
        finally
        {
            arg4 = arg4;
        }
    }
}

Introduced by c190f6b, cc @kunalspathak

@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 May 22, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 22, 2022
@ghost
Copy link

ghost commented May 22, 2022

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

Issue Details
// Generated by Fuzzlyn v1.5 on 2022-05-22 15:46:22
// Run on X64 Windows
// Seed: 6568846458402286114
// Reduced from 194.5 KiB to 0.5 KiB in 00:02:48
// Hits JIT assert in Release:
// Assertion failed '!foundDiff' in 'Program:M27(int,System.UInt64[][])' during 'Linear scan register alloc' (IL size 35; hash 0xf8af49d2; FullOpts)
// 
//     File: D:\a\_work\1\s\src\coreclr\jit\lsra.cpp Line: 2264
// 
public class Program
{
    public static ulong[] s_14;
    public static uint s_34;
    public static void Main()
    {
        var vr2 = new ulong[][]{new ulong[]{0}};
        M27(s_34, vr2);
    }

    public static void M27(uint arg4, ulong[][] arg5)
    {
        arg5[0][0] = arg5[0][0];
        for (int var7 = 0; var7 < 1; var7++)
        {
            return;
        }

        try
        {
            s_14 = arg5[0];
        }
        finally
        {
            arg4 = arg4;
        }
    }
}

Introduced by c190f6b, cc @kunalspathak

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged

Milestone: -

@jakobbotsch
Copy link
Member Author

Also the following:

// Generated by Fuzzlyn v1.5 on 2022-05-22 17:02:08
// Run on X64 Windows
// Seed: 16100522673054002921
// Reduced from 69.8 KiB to 0.8 KiB in 00:01:02
// Hits JIT assert in Release:
// Assertion failed 'cookie != nullptr' in 'Program:M47():bool' during 'Emit GC+EH tables' (IL size 66; hash 0x6cdf4e90; FullOpts)
// 
//     File: D:\a\_work\1\s\src\coreclr\jit\jiteh.cpp Line: 1086
// 
public class Program
{
    public static bool[][, ] s_2;
    public static short[, ][] s_8;
    public static bool[] s_10;
    public static ushort[][] s_29;
    public static void Main()
    {
        bool vr1 = M47();
    }

    public static bool M47()
    {
        bool var0 = default(bool);
        try
        {
            if (var0)
            {
                try
                {
                    if (s_10[0])
                    {
                        return s_2[0][0, 0];
                    }
                }
                finally
                {
                    s_8[0, 0][0] = 0;
                }
            }
        }
        finally
        {
            s_29 = s_29;
        }

        return true;
    }
}

@jakobbotsch jakobbotsch removed the untriaged New issue has not been triaged by the area owner label May 24, 2022
@kunalspathak
Copy link
Member

!foundDiff

This one is happening because we detect certain block is dead and remove the code inside it but we sometimes might decide to not delete the block. In those cases, we need to still make sure that we update liveness of variables. In #69421, I was only updating the liveness if we deleted the actual blocks.

cookie != nullptr

This one is interesting. We have chain of try-finally that looks like this. During dead block elimination, we eliminate BB08 and BB09. However, we fail to detect that BB11 could be eliminated as well because the only block that reaches BB11 is BB09. Going forward, we add labels to genMarkLabelsForCodegen and since no block is jumping to BB11 , we do not add label to it, do not generate a dedicated IG for it and hence do not have bbEmitCookie.

BB08 [0016]  1  1    BB04                  1       [???..???)-> BB15 (callf ) T1                  i internal LIR 
BB09 [0017]  1  1    BB15                  1       [???..???)-> BB11 (ALWAYS) T1      }           i internal LIR KEEP 
BB10 [0021]  2       BB02,BB07             1       [033..03E)-> BB14 (always)                     keep i LIR cfb cfe 
BB11 [0018]  1       BB09                  1       [???..???)-> BB17 (callf )                     i internal LIR 
BB12 [0019]  1       BB17                  1       [???..???)-> BB13 (ALWAYS)                     i internal LIR KEEP 

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label May 27, 2022
@JulieLeeMSFT JulieLeeMSFT added this to the 7.0.0 milestone May 27, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jun 6, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 7, 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.

3 participants