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 at /Users/runner/work/1/s/src/mono/mono/metadata/class-setup-vtable.c:1007, condition `is_ok (error)' not met, function:apply_override, VAR 1 (V) cannot be expanded in this context with 1 instantiations #70190

Closed
matthewslesinski opened this issue Jun 3, 2022 · 5 comments · Fixed by #74379
Assignees
Milestone

Comments

@matthewslesinski
Copy link

Description

When I'm trying to run my CLI project, I get this error thrown by Mono when it's loading my code. It gets thrown with both .NET 6 and 7 (preview 4), and my code works fine when I run it without Mono. In the past, I was blocked by a similar issue (#61244), and while that issue has since been fixed, this new one is coming up. I was able to determine a pretty simple reproduction example, and it's very similar to that other issue I just linked to, though definitely different (or maybe that previous bug was only partially fixed?), since I'm no longer seeing that previous issue occur. Also, I need to run my project with Mono because it's currently a functioning CLI application (when run without Mono) but I'm trying to eventually turn it into a Blazor WASM application.

It seems to occur when: One interface defines a method; a second interface, which is a child of the first and has at least one generic type variable, gives that method a default implementation; a third class/interface, which is a child of the second, overrides that default implementation with a different default implementation, has more generic type variables than the parent/second interface, and has its last generic type variable being passed to one of the parent/second interface's generic type variables.

Reproduction Steps

Try to run the following C# code with Mono:

public interface IA
{
    public void Foo();
}

public interface IB<T> : IA
{
    void IA.Foo() { }
}

public class C<U, V> : IB<V>
{
    void IA.Foo() { }
}

public class Program
{
    public static void Main()
    {
        IA c = new C<int, int>();
        c.Foo();
        Console.WriteLine("Your code should not reach here if you are running with Mono");
    }
}

I added these lines (inside a PropertyGroup) to my project's .csproj file to get it to run with Mono:

<UseMonoRuntime>true</UseMonoRuntime>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>

Expected behavior

Code runs successfully

Actual behavior

Assertion at /Users/runner/work/1/s/src/mono/mono/metadata/class-setup-vtable.c:1007, condition `is_ok (error)' not met, function:apply_override, VAR 1 (V) cannot be expanded in this context with 1 instantiations

This error gets thrown and aborts execution.

Regression?

No response

Known Workarounds

No response

Configuration

.NET Version: .NET 6 or .NET 7 (Preview 4)
OS: macOS Monterey
Architecture: x64
I don't think it's specific to this configuration
Issue appears in all browsers (when I try to reference my existing code from the sample Blazor WASM project)

Other information

Seems very similar to but is not the same as #61244

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 3, 2022
@ghost
Copy link

ghost commented Jun 3, 2022

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

Issue Details

Description

When I'm trying to run my CLI project, I get this error thrown by Mono when it's loading my code. It gets thrown with both .NET 6 and 7 (preview 4), and my code works fine when I run it without Mono. In the past, I was blocked by a similar issue (#61244), and while that issue has since been fixed, this new one is coming up. I was able to determine a pretty simple reproduction example, and it's very similar to that other issue I just linked to, though definitely different (or maybe that previous bug was only partially fixed?), since I'm no longer seeing that previous issue occur. Also, I need to run my project with Mono because it's currently a functioning CLI application (when run without Mono) but I'm trying to eventually turn it into a Blazor WASM application.

It seems to occur when: One interface defines a method; a second interface, which is a child of the first and has at least one generic type variable, gives that method a default implementation; a third class/interface, which is a child of the second, overrides that default implementation with a different default implementation, has more generic type variables than the parent/second interface, and has its last generic type variable being passed to one of the parent/second interface's generic type variables.

Reproduction Steps

Try to run the following C# code with Mono:

public interface IA
{
    public void Foo();
}

public interface IB<T> : IA
{
    void IA.Foo() { }
}

public class C<U, V> : IB<V>
{
    void IA.Foo() { }
}

public class Program
{
    public static void Main()
    {
        IA c = new C<int, int>();
        c.Foo();
        Console.WriteLine("Your code should not reach here if you are running with Mono");
    }
}

I added these lines (inside a PropertyGroup) to my project's .csproj file to get it to run with Mono:

<UseMonoRuntime>true</UseMonoRuntime>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>

Expected behavior

Code runs successfully

Actual behavior

Assertion at /Users/runner/work/1/s/src/mono/mono/metadata/class-setup-vtable.c:1007, condition `is_ok (error)' not met, function:apply_override, VAR 1 (V) cannot be expanded in this context with 1 instantiations

This error gets thrown and aborts execution.

Regression?

No response

Known Workarounds

No response

Configuration

.NET Version: .NET 6 or .NET 7 (Preview 4)
OS: macOS Monterey
Architecture: x64
I don't think it's specific to this configuration
Issue appears in all browsers (when I try to reference my existing code from the sample Blazor WASM project)

Other information

Seems very similar to but is not the same as #61244

Author: matthewslesinski
Assignees: -
Labels:

untriaged, area-AssemblyLoader-mono

Milestone: -

@radical
Copy link
Member

radical commented Jun 13, 2022

cc @lambdageek

@lambdageek lambdageek added this to the 7.0.0 milestone Jun 17, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jun 17, 2022
@lambdageek lambdageek added untriaged New issue has not been triaged by the area owner and removed untriaged New issue has not been triaged by the area owner labels Jun 17, 2022
@SamMonoRT
Copy link
Member

Moving to 8.0.0 milestone, and will consider a backport to earlier release ff the fix isn't risky cc @vargaz

@SamMonoRT SamMonoRT modified the milestones: 7.0.0, 8.0.0 Aug 10, 2022
@lambdageek
Copy link
Member

working on this one...

lambdageek added a commit to lambdageek/runtime that referenced this issue Aug 23, 2022
github-actions bot pushed a commit that referenced this issue Aug 24, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 24, 2022
lambdageek added a commit that referenced this issue Aug 25, 2022
…verrides (#74379)

Due to rearranging the logic in #64102 we already inflated the interfaces that are generic instances. Inflating again is wrong and will use the wrong generic context.

* use member access, not type punning

* Add regression test for #70190

* Assert that overrides are already inflated how we expect

* remove unused var

* Remove one more inflate, there's nothing to do

   In #64102 (comment) we concluded that this branch is never taken.

* Add link to issue for failing tests
@marek-safar marek-safar modified the milestones: 8.0.0, 7.0.0 Aug 25, 2022
carlossanlop pushed a commit that referenced this issue Aug 25, 2022
…applying DIM overrides (#74519)

* do we need to inflate here? it seems like we always get the right class

* use member access, not type punning

* Add regression test for #70190

* Assert code from #64102 is unreachable

In #64102 (comment)
we concluded that this branch is never taken.

* Assert that overrides are already inflated how we expect

* try to enable some disabled DIM tests

* remove unused var

* Don't assert - code is reachable, there's just nothing to do

* Add link to issue for failing tests

Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
Co-authored-by: Aleksey Kliger <aleksey@lambdageek.org>
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 25, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants