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 'isGeneralRegister(reg3)' on R2R_CG2 linux-arm64 outerloop #64936

Closed
am11 opened this issue Feb 7, 2022 · 19 comments · Fixed by #65048
Closed

Assertion failed 'isGeneralRegister(reg3)' on R2R_CG2 linux-arm64 outerloop #64936

am11 opened this issue Feb 7, 2022 · 19 comments · Fixed by #65048
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@am11
Copy link
Member

am11 commented Feb 7, 2022

Generate CORE_ROOT step of CoreCLR Pri1 Runtime Tests Run R2R_CG2 Linux arm64 checked leg failed this assertion https://dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_apis/build/builds/1597389/logs/1104:

  8 / 261 (2%, 1 failed): failed in 3497 msecs, exit code 134, expected 0: dotnet /__w/1/s/artifacts/bin/coreclr/Linux.arm64.Checked/x64/crossgen2/crossgen2.dll @/__w/1/s/artifacts/tests/coreclr/obj/Linux.arm64.Checked/crossgen.out/System.Security.Cryptography.dll.rsp
    /__w/1/s/src/coreclr/jit/emitarm64.cpp:6821
    Assertion failed 'isGeneralRegister(reg3)' in 'System.Security.Cryptography.X509Certificates.OpenSslX509ChainProcessor:FindChainViaAia(byref):Interop+Crypto+X509VerifyStatusCode:this' during 'Generate code' (IL size 473)
  10 / 261 (2%, 1 failed): launching: /__w/1/s/.dotnet/dotnet /__w/1/s/artifacts/bin/coreclr/Linux.arm64.Checked/x64/crossgen2/crossgen2.dll @/__w/1/s/artifacts/tests/coreclr/obj/Linux.arm64.Checked/crossgen.out/System.Net.Http.dll.rsp
@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 7, 2022
@ghost
Copy link

ghost commented Feb 7, 2022

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

Issue Details

Generate CORE_ROOT step of CoreCLR Pri1 Runtime Tests Run R2R_CG2 Linux arm64 checked leg failed this assertion https://dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_apis/build/builds/1597389/logs/1104:

  8 / 261 (2%, 1 failed): failed in 3497 msecs, exit code 134, expected 0: dotnet /__w/1/s/artifacts/bin/coreclr/Linux.arm64.Checked/x64/crossgen2/crossgen2.dll @/__w/1/s/artifacts/tests/coreclr/obj/Linux.arm64.Checked/crossgen.out/System.Security.Cryptography.dll.rsp
    /__w/1/s/src/coreclr/jit/emitarm64.cpp:6821
    Assertion failed 'isGeneralRegister(reg3)' in 'System.Security.Cryptography.X509Certificates.OpenSslX509ChainProcessor:FindChainViaAia(byref):Interop+Crypto+X509VerifyStatusCode:this' during 'Generate code' (IL size 473)
  10 / 261 (2%, 1 failed): launching: /__w/1/s/.dotnet/dotnet /__w/1/s/artifacts/bin/coreclr/Linux.arm64.Checked/x64/crossgen2/crossgen2.dll @/__w/1/s/artifacts/tests/coreclr/obj/Linux.arm64.Checked/crossgen.out/System.Net.Http.dll.rsp
Author: am11
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged

Milestone: -

@EgorBo EgorBo self-assigned this Feb 7, 2022
@EgorBo
Copy link
Member

EgorBo commented Feb 7, 2022

I can repro locally

@EgorBo EgorBo added this to the 7.0.0 milestone Feb 7, 2022
@EgorBo EgorBo removed the untriaged New issue has not been triaged by the area owner label Feb 7, 2022
@EgorBo
Copy link
Member

EgorBo commented Feb 7, 2022

@AndyAyersMS looks like fsub related, doesn't repro with --codegenopt:JitNoForwardSub=1 will investigate

@EgorBo
Copy link
Member

EgorBo commented Feb 7, 2022


*************** Starting PHASE Forward Substitution


===> BB01
    [000002]:  not asg (single-use lcl)
    [000006]:  not asg (single-use lcl)
    [000337]:  not asg (single-use lcl)
    [000347]:  not asg (single-use lcl)


===> BB02


===> BB03
    [000029]:  not asg (single-use lcl)
    [000357]:  no next stmt use
    [000359]:  [000354] is only use of [000358] (V30)  -- fwd subbing [000031]; new next stmt is
STMT00009 ( 0x028[E-] ... ??? )
               [000037] ----G-------              *  JTRUE     void  
               [000036] ----G-------              \--*  NE        int   
               [000034] ----G-------                 +--*  CAST      int <- bool <- int
               [000355] ----G-------                 |  \--*  EQ        int   
               [000351] ------------                 |     +--*  LCL_VAR   long   V29 tmp11        
               [000031] ------------                 |     \--*  LCL_VAR   long   V02 loc0         
               [000035] ------------                 \--*  CNS_INT   int    0

removing useless STMT00080 ( 0x028[E-] ... ??? )
               [000359] -A----------              *  ASG       long  
               [000358] D------N----              +--*  LCL_VAR   long   V30 tmp12        
               [000031] ------------              \--*  LCL_VAR   long   V02 loc0         
 from BB03
    [000357]:  [000351] is only use of [000356] (V29)  -- fwd subbing [000030]; new next stmt is
STMT00009 ( 0x028[E-] ... ??? )
               [000037] ----G-------              *  JTRUE     void  
               [000036] ----G-------              \--*  NE        int   
               [000034] ----G-------                 +--*  CAST      int <- bool <- int
               [000355] ----G-------                 |  \--*  EQ        int   
               [000030] ------------                 |     +--*  LCL_VAR   long   V06 loc4         
               [000031] ------------                 |     \--*  LCL_VAR   long   V02 loc0         
               [000035] ------------                 \--*  CNS_INT   int    0

removing useless STMT00079 ( 0x028[E-] ... ??? )
               [000357] -A----------              *  ASG       long  
               [000356] D------N----              +--*  LCL_VAR   long   V29 tmp11        
               [000030] ------------              \--*  LCL_VAR   long   V06 loc4         
 from BB03
    [000029]:  not asg (single-use lcl)


===> BB05
    [000040]:  not asg (single-use lcl)
    [000046]:  [000047] is only use of [000044] (V19)  potentially interacting effects
    [000050]:  not asg (single-use lcl)


===> BB07
    [000063]:  [000071] is only use of [000061] (V20)  [marking V32 as multi-reg-ret] -- fwd subbing [000058]; new next stmt is
STMT00085 ( ??? ... ??? )
               [000386] -ACXG-------              *  ASG       struct (copy)
               [000384] M------N----              +--*  LCL_VAR   struct<System.ReadOnlyMemory`1[System.Byte], 16> V32 tmp14        
               [000058] --CXG-------              \--*  CALL r2r_ind struct System.ReadOnlyMemory`1.op_Implicit
               [000060] n----------- arg0            \--*  OBJ       struct<System.ArraySegment`1[System.Byte], 16>
               [000059] ------------                    \--*  ADDR      byref 
               [000057] -------N----                       \--*  LCL_VAR   struct<System.ArraySegment`1[System.Byte], 16>(AX) V07 loc5         

removing useless STMT00014 ( 0x052[E-] ... 0x064 )
               [000063] -ACXG-------              *  ASG       struct (copy)
               [000061] M------N----              +--*  LCL_VAR   struct<System.ReadOnlyMemory`1[System.Byte], 16> V20 tmp2         
               [000058] --CXG-------              \--*  CALL r2r_ind struct System.ReadOnlyMemory`1.op_Implicit
               [000060] n----------- arg0            \--*  OBJ       struct<System.ArraySegment`1[System.Byte], 16>
               [000059] ------------                    \--*  ADDR      byref 
               [000057] -------N----                       \--*  LCL_VAR   struct<System.ArraySegment`1[System.Byte], 16>(AX) V07 loc5         
 from BB07
    [000386]:  no next stmt use
    [000389]:  no next stmt use
    [000367]:  not asg (single-use lcl)


===> BB09


===> BB10


===> BB11
    [000392]:  not asg (single-use lcl)
    [000074]:  not asg (single-use lcl)
    [000412]:  no next stmt use
    [000398]:  mismatched types (assignment)


===> BB17


===> BB18
    [000116]:  not asg (single-use lcl)


===> BB19
    [000430]:  no next stmt use
    [000424]:  not asg (single-use lcl)
    [000435]:  not asg (single-use lcl)


===> BB21


===> BB22


===> BB24


===> BB25


===> BB30


===> BB31


===> BB32


===> BB33


===> BB34
    [000448]:  no next stmt use
    [000451]:  no next stmt use
    [000467]:  no next stmt use
    [000461]:  [000462] is only use of [000460] (V42)  -- fwd subbing [000471]; new next stmt is
STMT00034 ( 0x0C4[E-] ... ??? )
               [000144] ------------              *  JTRUE     void  
               [000143] ------------              \--*  EQ        int   
               [000141] ------------                 +--*  CAST      int <- bool <- int
               [000445] ------------                 |  \--*  CAST      int <- bool <- int
               [000464] ------------                 |     \--*  EQ        int   
               [000471] ------------                 |        +--*  LCL_VAR   int    V48 tmp30        
               [000475] ------------                 |        \--*  LCL_VAR   int    V50 tmp32        
               [000142] ------------                 \--*  CNS_INT   int    0

removing useless STMT00103 ( INL10 @ 0x000[E-] ... ??? ) <- INL09 @ 0x000[E-] <- INLRT @ 0x0C4[E-]
               [000461] -A----------              *  ASG       int   
               [000460] D------N----              +--*  LCL_VAR   int    V42 tmp24        
               [000471] ------------              \--*  LCL_VAR   int    V48 tmp30        
 from BB34
    [000467]:  no next stmt use


===> BB35


===> BB36


===> BB37
    [000160]:  not asg (single-use lcl)
    [000170]:  not asg (single-use lcl)
    [000177]:  [000178] is only use of [000175] (V13)  V22 is address exposed
    [000181]:  not asg (single-use lcl)
    [000184]:  not asg (single-use lcl)


===> BB38
    [000322]:  [000323] is only use of [000320] (V27)  potentially interacting effects


===> BB39
    [000197]:  not asg (single-use lcl)
    [000202]:  not asg (single-use lcl)
    [000209]:  no next stmt use
    [000216]:  [000217] is only use of [000214] (V24)  potentially interacting effects


===> BB40


===> BB41
    [000246]:  [000247] is only use of [000245] (V25)  -- fwd subbing [000241]; new next stmt is
STMT00056 ( ??? ... ??? )
               [000249] -ACXG-------              *  ASG       long  
               [000248] *--X---N----              +--*  IND       long  
               [000241] ---X--------              |  \--*  COMMA     byref 
               [000235] ---X--------              |     +--*  BOUNDS_CHECK_Rng void  
               [000230] ------------              |     |  +--*  LCL_VAR   int    V15 loc13        
               [000234] ------------              |     |  \--*  LCL_FLD   int    V11 loc9         [+8] Fseq[_length]
               [000240] ------------              |     \--*  ADD       byref 
               [000239] ------------              |        +--*  LCL_FLD   byref  V11 loc9         [+0] Fseq[_pointer]
               [000238] ------------              |        \--*  MUL       long  
               [000236] ---------U--              |           +--*  CAST      long <- uint
               [000231] ------------              |           |  \--*  LCL_VAR   int    V15 loc13        
               [000237] ------------              |           \--*  CNS_INT   long   8
               [000244] --CXG-------              \--*  CALL r2r_ind long   Crypto.GetX509StackField
               [000242] ------------ arg0            +--*  LCL_VAR   ref    V09 loc7         
               [000243] ------------ arg1            \--*  LCL_VAR   int    V15 loc13        

removing useless STMT00055 ( 0x14F[E-] ... 0x161 )
               [000246] -A-X--------              *  ASG       byref 
               [000245] D------N----              +--*  LCL_VAR   byref  V25 tmp7         
               [000241] ---X--------              \--*  COMMA     byref 
               [000235] ---X--------                 +--*  BOUNDS_CHECK_Rng void  
               [000230] ------------                 |  +--*  LCL_VAR   int    V15 loc13        
               [000234] ------------                 |  \--*  LCL_FLD   int    V11 loc9         [+8] Fseq[_length]
               [000240] ------------                 \--*  ADD       byref 
               [000239] ------------                    +--*  LCL_FLD   byref  V11 loc9         [+0] Fseq[_pointer]
               [000238] ------------                    \--*  MUL       long  
               [000236] ---------U--                       +--*  CAST      long <- uint
               [000231] ------------                       |  \--*  LCL_VAR   int    V15 loc13        
               [000237] ------------                       \--*  CNS_INT   long   8
 from BB41


===> BB42


===> BB43


===> BB44
    [000271]:  not asg (single-use lcl)
    [000277]:  no next stmt use


===> BB45


===> BB46


===> BB47


===> BB48


===> BB49


===> BB50


===> BB51
    [000495]:  not asg (single-use lcl)


===> BB53
    [000513]:  no next stmt use


===> BB55


===> BB59


===> BB60


===> BB62


===> BB63


===> BB64


===> BB65

*************** Finishing PHASE Forward Substitution

@EgorBo
Copy link
Member

EgorBo commented Feb 7, 2022

The substitution that leads to the assert alone:

LocalAddressVisitor modified statement:
STMT00055 ( 0x14F[E-] ... 0x161 )
               [000246] -A-X--------              *  ASG       byref 
               [000245] D------N----              +--*  LCL_VAR   byref  V25 tmp7         
               [000241] ---X--------              \--*  COMMA     byref 
               [000235] ---X--------                 +--*  BOUNDS_CHECK_Rng void  
               [000230] ------------                 |  +--*  LCL_VAR   int    V15 loc13        
               [000234] ------------                 |  \--*  LCL_FLD   int    V11 loc9         [+8] Fseq[_length]
               [000240] ------------                 \--*  ADD       byref 
               [000239] ------------                    +--*  LCL_FLD   byref  V11 loc9         [+0] Fseq[_pointer]
               [000238] ------------                    \--*  MUL       long  
               [000236] ---------U--                       +--*  CAST      long <- uint
               [000231] ------------                       |  \--*  LCL_VAR   int    V15 loc13        
               [000237] ------------                       \--*  CNS_INT   long   8

LocalAddressVisitor visiting statement:
STMT00056 ( ??? ... ??? )
               [000249] -ACXG-------              *  ASG       long  
               [000248] *------N----              +--*  IND       long  
               [000247] ------------              |  \--*  LCL_VAR   byref  V25 tmp7         
               [000244] --C-G-------              \--*  CALL r2r_ind long   Crypto.GetX509StackField
               [000242] ------------ arg0            +--*  LCL_VAR   ref    V09 loc7         
               [000243] ------------ arg1            \--*  LCL_VAR   int    V15 loc13    

FSub:

               [000249] -ACXG-------              *  ASG       long  
               [000248] *--X---N----              +--*  IND       long  
               [000241] ---X--------              |  \--*  COMMA     byref 
               [000235] ---X--------              |     +--*  BOUNDS_CHECK_Rng void  
               [000230] ------------              |     |  +--*  LCL_VAR   int    V15 loc13        
               [000234] ------------              |     |  \--*  LCL_FLD   int    V11 loc9         [+8] Fseq[_length]
               [000240] ------------              |     \--*  ADD       byref 
               [000239] ------------              |        +--*  LCL_FLD   byref  V11 loc9         [+0] Fseq[_pointer]
               [000238] ------------              |        \--*  MUL       long  
               [000236] ---------U--              |           +--*  CAST      long <- uint
               [000231] ------------              |           |  \--*  LCL_VAR   int    V15 loc13        
               [000237] ------------              |           \--*  CNS_INT   long   8
               [000244] --CXG-------              \--*  CALL r2r_ind long   Crypto.GetX509StackField
               [000242] ------------ arg0            +--*  LCL_VAR   ref    V09 loc7         
               [000243] ------------ arg1            \--*  LCL_VAR   int    V15 loc13        

removing useless STMT00055 ( 0x14F[E-] ... 0x161 )
               [000246] -A-X--------              *  ASG       byref 
               [000245] D------N----              +--*  LCL_VAR   byref  V25 tmp7         
               [000241] ---X--------              \--*  COMMA     byref 
               [000235] ---X--------                 +--*  BOUNDS_CHECK_Rng void  
               [000230] ------------                 |  +--*  LCL_VAR   int    V15 loc13        
               [000234] ------------                 |  \--*  LCL_FLD   int    V11 loc9         [+8] Fseq[_length]
               [000240] ------------                 \--*  ADD       byref 
               [000239] ------------                    +--*  LCL_FLD   byref  V11 loc9         [+0] Fseq[_pointer]
               [000238] ------------                    \--*  MUL       long  
               [000236] ---------U--                       +--*  CAST      long <- uint
               [000231] ------------                       |  \--*  LCL_VAR   int    V15 loc13        
               [000237] ------------                       \--*  CNS_INT   long   8

@AndyAyersMS
Copy link
Member

See if #64933 fixes this?

@EgorBo
Copy link
Member

EgorBo commented Feb 8, 2022

See if #64933 fixes this?

Just checked - no, it doesn't

@EgorBo
Copy link
Member

EgorBo commented Feb 8, 2022

Minimal repro:

[MethodImpl(MethodImplOptions.NoInlining)]
void Test(Span<long> tempChain, int i)
{
    tempChain = tempChain.Slice(0, 1);
    tempChain[i] = Foo1();
}

[MethodImpl(MethodImplOptions.NoInlining)]
static long Foo1() => 0;

crossgen --targetos Linux, I wasn't able to repro it with alt jit

@AndyAyersMS
Copy link
Member

@EgorBo I'm happy to take a look too if you want...

@AndyAyersMS
Copy link
Member

Related to the BFIZ containment introduced in #61293? Seems like we're not giving the BFIZ a register somehow.

@EgorBo
Copy link
Member

EgorBo commented Feb 8, 2022

@AndyAyersMS BFIZ can be contained as part of LEA, but we should still have a register for underlying local. If you want I can take this issue back 🙂

@AndyAyersMS
Copy link
Member

Still a little puzzled but I think what's happening here is that the LEA is not contained, and the changes in #61293 may not handle that case? Note [000024] is missing c:

                                                              /--*  t15    int    
Generating: N041 (  2,  3) [000020] -c-------U--        t20 = *  CAST      long <- uint REG NA $240
Generating: N043 (  1,  2) [000021] -c----------        t21 =    CNS_INT   long   3 REG NA $280
                                                              /--*  t20    long   
                                                              +--*  t21    long   
Generating: N045 (  4,  6) [000022] -c----------        t22 = *  BFIZ      long   REG NA
                                                              /--*  t23    byref  
                                                              +--*  t22    long   
Generating: N047 (  8, 11) [000024] ------------        t24 = *  LEA(b+(i*1)+0) byref  REG x19

@EgorBo
Copy link
Member

EgorBo commented Feb 8, 2022

@AndyAyersMS from my understanding LEA should always be contained on arm (as part of IND). On x64 it can be not-contained since there is a real LEA instruction

@AndyAyersMS
Copy link
Member

If so, then we need to figure out what's blocking LEA containment. Possibly the new safety checks...? I will keep looking.

@AndyAyersMS
Copy link
Member

Ok, I think I have a fix. Lowering::LowerStoreIndirCommon is passing true to TryCreateAddrMode assuming that it's always ok to create LEAs. That is not the case (eg here there's a bounds check between). Not sure how disruptive this fix might be.

AndyAyersMS added a commit to AndyAyersMS/runtime that referenced this issue Feb 9, 2022
At least on arm64, where LEAs must be contained.

Fixes dotnet#64936.
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 9, 2022
@AndyAyersMS
Copy link
Member

@am11 which outerloop pipeline was this? I would like to trigger it on the fix.

@BruceForstall
Copy link
Member

It happens in https://dev.azure.com/dnceng/public/_build?definitionId=833&_a=summary

(don't know which pipeline the issue came from)

@am11
Copy link
Member Author

am11 commented Feb 9, 2022

Yes it was runtime-coreclr outerloop pipeline and the leg CoreCLR Pri1 Runtime Tests Run R2R_CG2 Linux arm64 checked was failing on Generate CORE_ROOT step.

AndyAyersMS added a commit that referenced this issue Feb 10, 2022
At least on arm64, where LEAs must be contained.

Fixes #64936.
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 10, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 12, 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.

4 participants