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

JIT: Assertion failed '!"Write to unaliased local overlaps outstanding read"' during 'Rationalize IR' #77773

Closed
jakobbotsch opened this issue Nov 2, 2022 · 2 comments · Fixed by #77848
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

jakobbotsch commented Nov 2, 2022

// Generated by Fuzzlyn v1.5 on 2022-11-02 10:14:49
// Run on X64 Windows
// Seed: 14352496230403376157
// Reduced from 191.3 KiB to 0.5 KiB in 00:01:55
// Hits JIT assert in Release:
// Assertion failed '!"Write to unaliased local overlaps outstanding read"' in 'Program:Main(Fuzzlyn.ExecutionServer.IRuntime)' during 'Rationalize IR' (IL size 42; hash 0xade6b36b; FullOpts)
//
//     File: C:\dev\dotnet\runtime3\src\coreclr\jit\lir.cpp Line: 1407
//
public struct S0
{
    public int F1;
}

public struct S2
{
    public uint F0;
    public ushort F1;
}

public class Program
{
    public static S2 s_1;
    public static S2 s_16;
    public static sbyte[][] s_20;
    public static int[] s_21;
    public static void Main()
    {
        var vr9 = new S0();
        s_1.F0 <<= M41(vr9, ref s_16.F1);
    }

    public static sbyte M41(S0 argThis, ref ushort arg1)
    {
        argThis.F1 = s_21[0];
        return s_20[0][0];
    }
}

Full output:

                      [000083] -----------                            IL_OFFSET void   INLRT @ 0x000[E-]
       N001 (  1,  1) [000047] -----------                   t47 =    CNS_INT   int    0 $80
                                                                   ┌──▌  t47    int
       N003 (  5,  4) [000048] DA---------STORE_LCL_VAR int    V04 tmp3         d:2
                      [000084] -----------                            IL_OFFSET void   INLRT @ 0x008[E-]
       N001 (  2, 10) [000009] -----------                    t9 =    CNS_INT   long   0x7ff9a30af770 $100
       N002 (  1,  1) [000010] -----------                   t10 =    CNS_INT   int    3 $82
                                                                   ┌──▌  t9     long   arg0 in rcx
                                                                   ├──▌  t10    int    arg1 in rdx
       N003 ( 17, 18) [000011] H-CXG------                   t11 =CALL help long   HELPER.CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE $1c1
                                                                   ┌──▌  t11    long
       N005 ( 17, 18) [000077] DA-XG------STORE_LCL_VAR long   V08 cse0         d:1
       N008 (  3, 10) [000004] I----------                    t4 =    CNS_INT(h) long   0x1432dc01ec0 static box ptr $200
                                                                   ┌──▌  t4     long
       N009 (  5, 12) [000005] #----------                    t5 =IND       ref    $240
       N010 (  1,  1) [000006] -----------                    t6 =    CNS_INT   long   8 Fseq[s_1] $102
                                                                   ┌──▌  t5     ref
                                                                   ├──▌  t6     long
       N011 (  7, 14) [000007] -----------                    t7 =ADD       byref  $280
                                                                   ┌──▌  t7     byref
       N014 ( 25, 33) [000050] DA-XG------STORE_LCL_VAR byref  V05 tmp4         d:2
       N015 (  1,  1) [000051] -----------                   t51 =    LCL_VAR   byref  V05 tmp4         u:2 $280
                                                                   ┌──▌  t51    byref
       N016 (  2,  2) [000052] -----O-----NULLCHECK byte   $VN.Void
       N001 (  1,  1) [000018] -----------                   t18 =    LCL_VAR   byref  V05 tmp4         u:2 $280
                                                                   ┌──▌  t18    byref
       N002 (  3,  2) [000019] n---GO-----                   t19 =IND       int    <l:$340, c:$380>
                                                                   ┌──▌  t19    int
       N004 (  3,  3) [000036] DA--GO-----STORE_LCL_VAR int    V03 tmp2         d:2
read:  N001 (  1,  1) [000017] -----------                   t17 =    LCL_VAR   byref  V05 tmp4         u:2 (last use) $280
       N003 (  1,  1) [000081] -----------                   t81 =    CNS_INT   int    0 $80
                                                                   ┌──▌  t81    int
       N005 (  1,  3) [000073] DA---------STORE_LCL_VAR int    V07 tmp6         d:2
       N006 (  3, 10) [000021] I----------                   t21 =    CNS_INT(h) long   0x1432dc01ec8 static box ptr $204
                                                                   ┌──▌  t21    long
       N007 (  5, 12) [000022] #----------                   t22 =IND       ref    $241
       N008 (  1,  1) [000023] -----------                   t23 =    CNS_INT   long   8 Fseq[s_16] $102
                                                                   ┌──▌  t22    ref
                                                                   ├──▌  t23    long
       N009 (  7, 14) [000024] -----------                   t24 =ADD       byref  $281
                                                                   ┌──▌  t24    byref
write: N011 (  7, 14) [000059] DA--G------STORE_LCL_VAR byref  V05 tmp4         d:3
       N012 (  1,  1) [000063] -----------                   t63 =    LCL_VAR   byref  V05 tmp4         u:3 (last use) $281
       N013 (  1,  1) [000064] -----------                   t64 =    CNS_INT   long   4 $105
                                                                   ┌──▌  t63    byref
                                                                   ├──▌  t64    long
       N014 (  3,  3) [000065] -----------                   t65 =ADD       byref  $282
                                                                   ┌──▌  t65    byref
       N017 ( 10, 17) [000070] DA--GO-----STORE_LCL_VAR byref  V06 tmp5         d:2
       N018 (  1,  1) [000071] -----------                   t71 =    LCL_VAR   byref  V06 tmp5         u:2 (last use) $282
       N019 (  1,  1) [000082] -----------                   t82 =    CNS_INT   int    0 $80
                                                                   ┌──▌  t71    byref  arg1 in rdx
                                                                   ├──▌  t82    int    arg0 in rcx
       N020 ( 33, 29) [000032] --CXGO-----                   t32 =CALL      int    Program.M41 $381
       N021 (  1,  1) [000039] -----------                   t39 =    CNS_INT   int    31 $83
                                                                   ┌──▌  t32    int
                                                                   ├──▌  t39    int
       N022 ( 35, 31) [000040] ---XGO-----                   t40 =AND       int    $341
       N023 (  1,  1) [000037] -----------                   t37 =    LCL_VAR   int    V03 tmp2         u:2 (last use) <l:$340, c:$380>
                                                                   ┌──▌  t37    int
                                                                   ├──▌  t40    int
       N024 ( 40, 33) [000041] ---XGO-----                   t41 =LSH       int    <l:$342, c:$343>
                                                                   ┌──▌  t17    byref
                                                                   ├──▌  t41    int
user:                 [000085] -ACXGO-----STOREIND  int
                      [000086] -----------                            IL_OFFSET void   INLRT @ 0x029[E-]
       N001 (  0,  0) [000044] -----------                            RETURN    void   $VN.Void

Assert failure(PID 33568 [0x00008320], Thread: 26964 [0x6954]): Assertion failed '!"Write to unaliased local overlaps outstanding read"' in 'Program:Main()' during 'Rationalize IR' (IL size 42; hash 0xcb019401; FullOpts)

    File: C:\dev\dotnet\runtime3\src\coreclr\jit\lir.cpp Line: 1407
    Image: C:\dev\dotnet\runtime3\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\corerun.exe

Looks introduced/exposed by #77641, cc @SingleAccretion

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

ghost commented Nov 2, 2022

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

Issue Details
// Generated by Fuzzlyn v1.5 on 2022-11-02 10:14:49
// Run on X64 Windows
// Seed: 14352496230403376157
// Reduced from 191.3 KiB to 0.5 KiB in 00:01:55
// Hits JIT assert in Release:
// Assertion failed '!"Write to unaliased local overlaps outstanding read"' in 'Program:Main(Fuzzlyn.ExecutionServer.IRuntime)' during 'Rationalize IR' (IL size 42; hash 0xade6b36b; FullOpts)
//
//     File: C:\dev\dotnet\runtime3\src\coreclr\jit\lir.cpp Line: 1407
//
public struct S0
{
    public int F1;
}

public struct S2
{
    public uint F0;
    public ushort F1;
}

public class Program
{
    public static S2 s_1;
    public static S2 s_16;
    public static sbyte[][] s_20;
    public static int[] s_21;
    public static void Main()
    {
        var vr9 = new S0();
        s_1.F0 <<= M41(vr9, ref s_16.F1);
    }

    public static sbyte M41(S0 argThis, ref ushort arg1)
    {
        argThis.F1 = s_21[0];
        return s_20[0][0];
    }
}

Looks introduced/exposed by #77641, cc @SingleAccretion

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch jakobbotsch removed the untriaged New issue has not been triaged by the area owner label Nov 2, 2022
@jakobbotsch jakobbotsch added this to the 8.0.0 milestone Nov 2, 2022
@SingleAccretion SingleAccretion self-assigned this Nov 2, 2022
@SingleAccretion
Copy link
Contributor

SingleAccretion commented Nov 2, 2022

This is a tricky issue. Distilled, we have (local) copy propagation replacing a use of a local that will redefined before being used by the parent, i. e.

USER
  op1: LCL_VAR V02 => V05
  op2: ...
       STORE_LCL_VAR<V05>(...)

(The V05 local is a "big offset morphing" temp)

This is a fundamental limitation that we are running into here, the only way to solve it is through some workaround...

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Nov 3, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Nov 4, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Dec 5, 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