Skip to content

[mono] class-setup-vtable.c:1747, condition `is_ok (error)' not met, function:mono_class_setup_vtable_general, VAR 1 (T) cannot be expanded in this context with 1 instantiations #61244

Closed

Description

@JinShil

Description

Using Blazor WebAssembly project. I have a class hierarchy that seems to cause an assertion failure in the mono runtime. I've created a solution and reduced the code as much as I can and attached it to this issue. The project works fine in a Blazor Server (non-WebAssembly) project.

The projects were created with Visual Studio 2022 using the 6.0.100-rc.2.21505.57 SDK.

ComfileTech.Framework.zip

Reproduction Steps

Open the attached solution and run the project ending in ".Server" (ASP.Net hosted Blazor Web Assembly project). View the result in a web browser.

Expected behavior

No assertion failure.

Actual behavior

Assertion failure. See image below:

image

Regression?

I have not tested this code in a prior version of the .Net Framework.

Known Workarounds

No known workarounds.

Configuration

6.0.100-rc.2.21505.57
Tested on Windows 10 64bit
Tested using the Brave web browser.

Other information

No response

Activity

  1. ghost added
    untriaged
    on Nov 5, 2021
  2. lewing commented on Nov 5, 2021

    @lewing
    Member
  3. JinShil commented on Nov 10, 2021

    @JinShil
    ContributorAuthor

    A little more information: I tried with the latest .Net 6 SDK release (6.0.100) and the problem persists.

    I attempted to work around the issue by adding <RunAOTCompilation>true</RunAOTCompilation> to the .Client project and it resulted in the following error.

    Assertion at D:\a\_work\1\s\src\mono\mono\metadata\class-setup-vtable.c:1747, condition `is_ok (error)' not met, function:mono_class_setup_vtable_general, VAR 1 (T) cannot be expanded in this context with 1 instantiations
    
  4. added this to the 6.0.x milestone on Nov 10, 2021
  5. removed
    untriaged
    on Nov 10, 2021
  6. lambdageek commented on Nov 10, 2021

    @lambdageek
    Member
  7. lambdageek commented on Nov 10, 2021

    @lambdageek
    Member

    It's the override that implements ComfileTech.Framework.IGetSetChangeValue`1<T>:add_Changing (System.Action`1<ComfileTech.Framework.IChangeEventArgs`2<ComfileTech.Framework.IGetSetChangeValue`1<T>, T>>) with ComfileTech.Framework.IGetSetChangeValue`2:ComfileTech.Framework.IGetSetChangeValue<T>.add_Changing (System.Action`1<ComfileTech.Framework.IChangeEventArgs`2<ComfileTech.Framework.IGetSetChangeValue`1<T>, T>>)

    ie, it's here:

        public interface IGetSetChangeValue<out TProperty, T> : IGetChangeValue<TProperty, T>, IGetSetChangeValue<T>
            where TProperty : IGetSetChangeValue<TProperty, T>
        { 
            new event Action<IChangeEventArgs<TProperty, T>>? Changing;
            new event Action<IChangeEventArgs<TProperty, T>>? Changed;
    
            event Action<IChangeEventArgs<IGetSetChangeValue<T>, T>>? IGetSetChangeValue<T>.Changing  
            {
                add { Changing += (Action<IChangeEventArgs<TProperty, T>>?)value; }      // this override
                remove { Changing -= (Action<IChangeEventArgs<TProperty, T>>?)value; }
            }
  8. lambdageek commented on Nov 10, 2021

    @lambdageek
    Member

    Shorter repro

    using System;
    
    
    public interface I1<T> {
        void Foo (I1<T> x);
    }
    
    public interface I2<TSelf,T> : I1<T> where TSelf : I2<TSelf, T> {
        void I1<T>.Foo (I1<T> x) {
    	throw new Exception ("e");
        }
    }
    
    public class C : I2<C, int> {
        
    }
    
    public class Program {
        public static void Main () {
    	var isMono = typeof(object).Assembly.GetType("Mono.RuntimeStructs") != null;
    	Console.WriteLine ($"isMono = {isMono}");
    
    	I2<C,int> v = new C();
    	v.Foo(null!);
        }
    }

    (with these additions to the .csproj)

      <PropertyGroup>
        <RuntimeIdentifier>osx-x64</RuntimeIdentifier>
        <UseMonoRuntime>true</UseMonoRuntime>
        <SelfContained>true</SelfContained>
      </PropertyGroup>
  9. changed the title [-]Blazor WebAssembly: Assertion at /__w/1/s/src/mono/mono/metadata/class-setup-vtable.c:1747[/-] [+][mono] class-setup-vtable.c:1747, condition `is_ok (error)' not met, function:mono_class_setup_vtable_general, VAR 1 (T) cannot be expanded in this context with 1 instantiations[/+] on Nov 10, 2021
  10. removed
    arch-wasm
    on Nov 10, 2021
  11. matthewslesinski commented on Dec 9, 2021

    @matthewslesinski

    I've also encountered this issue. When trying to understand what causes this so I could know what to change in the project I'm writing until this gets fixed, I've condensed the above shorter repro into an even shorter one. In case it helps, I figured I'd post it.

    public interface I1<T>
    {
        void Foo();
    }
    
    public interface I2<T, T2> : I1<T>
    {
        void I1<T>.Foo()
        {
            Console.WriteLine("Error not reproduced");
        }
    }
    
    public class C : I2<int, int>
    {
    }
    
    public class Program
    {
        public static void Main()
        {
            var isMono = typeof(object).Assembly.GetType("Mono.RuntimeStructs") != null;
            Console.WriteLine($"isMono = {isMono}");
    
            I1<int> v = new C();
            v.Foo();
        }
    }
    

    If I remove either of the type variables in I2 or move the implementation of Foo in I2 to either I1 or C, the error doesn't occur.

  12. JamesYFC commented on Jan 12, 2022

    @JamesYFC

    In Unity's Mono at least, I don't even need to call Foo() to get this error. Just the instantiation line will trigger it.

  13. ghost added
    in-pr
    on Jan 21, 2022
  14. added a commit that references this issue on Feb 1, 2022
    e37946b
  15. added a commit that references this issue on Feb 2, 2022
    d8d4441
  16. added a commit that references this issue on Feb 3, 2022
    c5ef615
  17. ghost removed
    in-pr
    on Feb 7, 2022
  18. added 2 commits that reference this issue on Feb 7, 2022
    7b8551f
    6171c87
  19. ghost locked as resolved and limited conversation to collaborators on Mar 10, 2022
  20. added 2 commits that reference this issue on Apr 27, 2022
    52fb081
    f2be0d7
  21. added a commit that references this issue on Mar 23, 2024
    0cefee0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions