Skip to content

[libraries-pgo] Assertion failed '(igInLoop->igLoopBackEdge == nullptr) || (igInLoop->igLoopBackEdge == igLoopHeader)' during 'Generate code' #70152

Closed

Description

@jakobbotsch

Pipeline run: https://dev.azure.com/dnceng/public/_build/results?buildId=1802466&view=results
Job: Libraries Test Run checked coreclr windows x86 Release
Link: https://dev.azure.com/dnceng/public/_build/results?buildId=1802466&view=ms.vss-test-web.build-test-results-tab&runId=48045838&resultId=197326&paneView=dotnet-dnceng.dnceng-build-release-tasks.helix-test-information-tab
Console log: https://helixre107v0xdeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-68703-merge-d3c3c7af73024cbc8d/System.Globalization.Tests/1/console.afb8732b.log?helixlogtype=result

Assert failure(PID 4900 [0x00001324], Thread: 4476 [0x117c]): Assertion failed '(igInLoop->igLoopBackEdge == nullptr) || (igInLoop->igLoopBackEdge == igLoopHeader)' in 'System.Number:Dragon4(long,int,int,bool,int,bool,System.Span`1[Byte],byref):int' during 'Generate code' (IL size 1229; hash 0x351b3d9f; Tier1)

    File: D:\a\_work\1\s\src\coreclr\jit\emit.cpp Line: 5146
    Image: C:\h\w\B6DB09CD\p\dotnet.exe

Activity

  1. ghost added
    untriaged
    on Jun 2, 2022
  2. ghost removed
    untriaged
    on Jun 2, 2022
  3. ghost added
    area-CodeGen-coreclr
    on Jun 2, 2022
  4. added this to the 7.0.0 milestone on Jun 8, 2022
  5. AndyAyersMS commented on Jun 17, 2022

    @AndyAyersMS
    Member

    I can repro this (as well as another assert) though it is intermittent. I think it happens when trying to print the overall elapsed time for the test, which can vary.

    c:\repos\runtime3\artifacts\bin\System.Globalization.Tests\Release\net7.0>dotnet.exe exec --runtimeconfig System.Globalization.Tests.runtimeconfig.json --depsfile System.Globalization.Tests.deps.json xunit.console.dll System.Globalization.Tests.dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing
      Discovering: System.Globalization.Tests (method display = ClassAndMethod, method display options = None)
      Discovered:  System.Globalization.Tests (found 450 of 455 test cases)
      Starting:    System.Globalization.Tests (parallel test collections = on, max threads = 12)
        System.Globalization.Tests.CultureInfoAll.TestAllCultures_Nls [SKIP]
          Condition(s) not met: "IsNlsGlobalization"
    
    Assert failure(PID 14232 [0x00003798], Thread: 13740 [0x35ac]): Assertion failed 'firstILBlock->hasProfileWeight()' in 'System.Globalization.CalendarData:GetCalendarsCore(System.String,bool,System.Globalization.CalendarId[]):int' during 'Compute edge weights (1, false)' (IL size 203; hash 0x26a1ac90; Tier1)
    
        File: C:\repos\runtime3\src\coreclr\jit\fgprofile.cpp Line: 3547
        Image: c:\repos\runtime3\artifacts\bin\testhost\net7.0-windows-Release-x86\dotnet.exe
    
      Finished:    System.Globalization.Tests
    === TEST EXECUTION SUMMARY ===
       System.Globalization.Tests  Total: 2587, Errors: 0, Failed: 0, Skipped: 1, Time: 33.449s
    
    Assert failure(PID 14232 [0x00003798], Thread: 13740 [0x35ac]): Assertion failed '(igInLoop->igLoopBackEdge == nullptr) || (igInLoop->igLoopBackEdge == igLoopHeader)' in 'System.Number:Dragon4(long,int,int,bool,int,bool,System.Span`1[Byte],byref):int' during 'Generate code' (IL size 1229; hash 0x351b3d9f; Tier1)
    
        File: C:\repos\runtime3\src\coreclr\jit\emit.cpp Line: 5423
        Image: c:\repos\runtime3\artifacts\bin\testhost\net7.0-windows-Release-x86\dotnet.exe
    
  6. AndyAyersMS commented on Jun 17, 2022

    @AndyAyersMS
    Member

    Trying to catch the second assert via SPMI but so far it's not reproing readily. Also I get a bunch of errorsunder SPMI collect, likely from child processes not playing along properly:

    Microsoft.DotNet.XUnitConsoleRunner v2.5.0 (32-bit .NET 7.0.0-dev)
      Discovering: System.Globalization.Tests (method display = ClassAndMethod, method display options = None)
      Discovered:  System.Globalization.Tests (found 455 test cases)
      Starting:    System.Globalization.Tests (parallel test collections = on, max threads = 12)
    ERROR: LoadRealJitLib - LoadLibrary failed to load 'c:\home\clrjit2.dll' (0x0000007e)
    ERROR: LoadRealJitLib - LoadLibrary failed to load 'c:\home\clrjit2.dll' (0x0000007e)
    Fatal error. Failed to load JIT compiler
        System.Globalization.Tests.CultureInfoAll.TestAllCultures_Nls [SKIP]
          Condition(s) not met: "IsNlsGlobalization"
    ERROR: LoadRealJitLib - LoadLibrary failed to load 'c:\home\clrjit2.dll' (0x0000007e)
    ERROR: LoadRealJitLib - LoadLibrary failed to load 'c:\home\clrjit2.dll' (0x0000007e)
    Fatal error. Failed to load JIT compiler
    

    not sure where it's getting that folder or jit name from.

  7. AndyAyersMS commented on Jun 18, 2022

    @AndyAyersMS
    Member

    Ok, above was operator error (not passing all the args to xunit, so remote executor did not properly launch the child runtime).

    Can repro and capture via SPMI. Last bit of the jit dump is:

    *************** In getLoopSize() for G_M49760_IG72
       G_M49760_IG72 has 87 bytes.
       G_M49760_IG73 has 4 bytes.
       G_M49760_IG74 has 28 bytes. but ends with align instruction, taking off 15 bytes.
       G_M49760_IG75 has 3 bytes.
       G_M49760_IG76 has 26 bytes. but ends with align instruction, taking off 15 bytes. -- Found the back edge.
    loopSize of G_M49760_IG72 = 118 bytes.
    ;; Skip alignment: 'Loop at G_M49760_IG72 PaddingNeeded= 10, MaxPadding= 2, LoopSize= 118, AlignmentBoundary= 16B.'
    ;; Calculated padding to add 0 bytes to align G_M49760_IG72 at 16B boundary.
    Adjusted alignment for G_M49760_IG72 from 15 to 0.
    Adjusted size of G_M49760_IG62 from 23 to 8.
    Adjusted offset of G_M49760_IG63 from 0724 to 06F7
    Adjusted offset of G_M49760_IG64 from 072D to 0700
    Adjusted offset of G_M49760_IG65 from 073C to 070F
    Adjusted offset of G_M49760_IG66 from 074B to 071E
    Adjusted offset of G_M49760_IG67 from 0754 to 0727
    Adjusted offset of G_M49760_IG68 from 075E to 0731
    Adjusted offset of G_M49760_IG69 from 076C to 073F
    Adjusted offset of G_M49760_IG70 from 077A to 074D
    Adjusted offset of G_M49760_IG71 from 07D0 to 07A3
    Adjusted offset of G_M49760_IG72 from 0803 to 07D6
    Adjusted offset of G_M49760_IG73 from 085A to 082D
    Adjusted offset of G_M49760_IG74 from 085E to 0831
      Adjusting 'align' instruction in IG74 that is targeted for IG75 
    *************** In getLoopSize() for G_M49760_IG75
       G_M49760_IG75 has 3 bytes.
       G_M49760_IG76 has 26 bytes.
    

    And we assert here because IG76 thinks it is part of the IG72 loop, but we are processing the IG75 loop.

    On the block level we seem to have interleaved blocks from two different loops. IG72 is BB132, IG75 is BB134, IG76 is BB279

    BB132 [0284]  2       BB131,BB279           4.11      201  5 [2A0..2A1)-> BB279 ( cond )                     i Loop Loop0 label bwd bwd-target bwd-src IBC LIR align 
    BB133 [0285]  2       BB132,BB134         320.26    15693    [2A0..2A1)-> BB137 ( cond )                     i label bwd IBC LIR 
    BB136 [0288]  1       BB133               316.15    15491  6 [2A0..2A1)-> BB137 ( cond )                     i bwd bwd-src IBC LIR 
    BB134 [0286]  1       BB136               316.15    15491  6 [2A0..2A1)-> BB133 (always)                     i Loop Loop0 bwd bwd-target IBC LIR align 
    BB279 [0441]  1       BB132                 2.05      101    [???..???)-> BB132 (always)                     internal label bwd IBC LIR 
    BB224 [0385]  1       BB261                8202.   401906 17 [3BB..3BC)                                      i Loop Loop0 label bwd bwd-target IBC LIR align 
    BB225 [0386]  2       BB223,BB224          8251.   404298 17 [3BB..3BC)-> BB227 ( cond )                     i label bwd IBC LIR 
    BB226 [0387]  1       BB225                8251.   404298 17 [3BB..3BC)-> BB227 ( cond )                     i bwd bwd-src IBC LIR 
    BB261 [0423]  1       BB226                8202.          17 [???..???)-> BB224 (always)                     internal LIR 
    BB137 [0289]  2       BB133,BB136           4.11      201    [2A0..2A1)                                      i label bwd IBC LIR 
    

    Seems like we get into trouble with loop 6: BB134 is marked as the head to align, but BB136 comes before it and is also in loop 6.

    This state of affairs comes about during Optimize layout, for convoluted reasons. The logic there is suspect, but I think the right fix is to update the alignment marking code to tolerate finding a loop block that isn't the header before it sees other blocks in the loop, and just bypass alignment for that loop or something.

  8. ghost added
    in-pr
    on Jun 18, 2022
  9. added a commit that references this issue on Jun 21, 2022
    95138dd
  10. ghost removed
    in-pr
    on Jun 21, 2022
  11. ghost locked as resolved and limited conversation to collaborators on Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions