Skip to content

Assert failure: Compiler optimization assumption invalid: FAILED: pMgr != 0 #70259

Closed

Description

@BruceForstall

Pipeline: runtime-coreclr libraries-jitstress
Configs:

  • System.Text.RegularExpressions.Unit.Tests, net7.0-windows-Release-x86-CoreCLR_checked-jitstress1-Windows.10.Amd64.Open
  • System.Text.RegularExpressions.Unit.Tests, net7.0-windows-Release-x86-CoreCLR_checked-jitstress1_tiered-Windows.10.Amd64.Open
  • System.Text.RegularExpressions.Unit.Tests, net7.0-windows-Release-x86-CoreCLR_checked-tailcallstress-Windows.10.Amd64.Open

Also in LibraryImportGenerator.Unit.Tests, same configs.

https://dev.azure.com/dnceng/public/_build/results?buildId=1807559&view=ms.vss-test-web.build-test-results-tab

Looks like a VSD assert.

@dotnet/jit-contrib JIT issue?

Activity

  1. added this to the 7.0.0 milestone on Jun 5, 2022
  2. jkotas commented on Jun 5, 2022

    @jkotas
    Member

    This looks like JIT stress issue. JIT stress converted delegate call to tailcall. This conversion is not valid when the delegate points to virtual interface method.

  3. BruceForstall commented on Jun 5, 2022

    @BruceForstall
    ContributorAuthor
  4. jakobbotsch commented on Jun 5, 2022

    @jakobbotsch
    Member

    Probably #70033, though it is curious that this seemingly used to work. Maybe something rotted in the period that the JIT helper was not being used.

  5. self-assigned this
    on Jun 5, 2022
  6. jakobbotsch commented on Jun 5, 2022

    @jakobbotsch
    Member

    @jkotas

    This looks like JIT stress issue. JIT stress converted delegate call to tailcall. This conversion is not valid when the delegate points to virtual interface method.

    What exactly do you mean by virtual interface method here? Do you mean any call that may go through VSD?

  7. jkotas commented on Jun 5, 2022

    @jkotas
    Member

    Here is what is happening based on the crash dump:

    // This delegate points to shuffle thunk that in turn points to VSD stub
    // The VSD stub expects the callsite to be VSD DelegateCallSite.
    var d = typeof(IFace).GetMethod("Method").CreateDelegate<Action<IFace>>();
    
    var c = new ClassA();
    
    // JIT stress converted this to tailcall. The callsite is not identified as 
    // DelegateCallSite anymore and that's why we get the assert.
    d(c); 
    
    public class ClassA : IFace
    {
        public virtual void Method() { Console.WriteLine("Method"); }
    }
    
    public interface IFace
    {
        public void Method();
    }
    

    it is curious that this seemingly used to work.

    These delegates pointing to VSD stubs are very rare. It is quite possible that it was broken for a long time and we just got lucky that the JIT stress did not hit it before.

  8. jakobbotsch commented on Jun 5, 2022

    @jakobbotsch
    Member

    These delegates pointing to VSD stubs are very rare. It is quite possible that it was broken for a long time and we just got lucky that the JIT stress did not hit it before.

    I see, thanks for the example. In practice does this mean that tail prefixed delegate calls cannot be done through the old mechanism?

  9. jkotas commented on Jun 5, 2022

    @jkotas
    Member

    Right.

    It may be possible to fix up the x86 JIT_TailCall helper to handle this case, but I do not think that it is worth it.

  10. jakobbotsch commented on Jun 5, 2022

    @jakobbotsch
    Member

    The other half of why we may not have seen this before is that isCallRelativeIndirect inside StubCallSite::StubCallSite needs to pass, i.e. the tailcaller's caller need to be on the form call [rel32]. If that check does not pass the VSD resolver properly sees the call as a delegate call.

  11. added a commit that references this issue on Jun 5, 2022
    77a4450
  12. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 5, 2022
  13. added a commit that references this issue on Jun 7, 2022
    caff7b0
  14. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 7, 2022
  15. ghost locked as resolved and limited conversation to collaborators on Jul 7, 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-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIblocking-clean-ci-optionalBlocking optional rolling runs

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions