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

Don't return null target methods in GetInterfaceMap for abstract classes, or classes using DIMs #53972

Merged
merged 2 commits into from
Jun 15, 2021

Conversation

lambdageek
Copy link
Member

@lambdageek lambdageek commented Jun 10, 2021

If the interface method is reabstracted, and either the found implementation method is abstract, or the found implementation method is from another DIM (meaning neither klass nor any of its ancestor classes implemented the
method), then say the target method is null. Otherwise return the found implementation method, even if it is abstract.

Fixes #53933

@ghost
Copy link

ghost commented Jun 10, 2021

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

Issue Details

The only case where we should be getting nulls back is for reabstracted DIMs. Otherwise we should be returning either the abstract method from the abstract class (or its ancestor classes) or a default interface method.

Fixes #53933

Author: lambdageek
Assignees: -
Labels:

area-VM-meta-mono

Milestone: -

@lambdageek
Copy link
Member Author

Once it's reviewed, we need to sync this back to mono/mono

@lambdageek
Copy link
Member Author

Failures are related. Needs more work

If the iterface method is reabstracted, and either the found implementation
method is abstract, or the found implementation method is from another
DIM (meaning neither klass nor any of its ancestor classes implemented the
method), then say the target method is null.  Otherwise return the found
implementation method, even if it is abstract, unless we found a reabstracted
method in a non-abstract class

Fixes dotnet#53933
@lambdageek lambdageek marked this pull request as ready for review June 10, 2021 19:23
@lambdageek
Copy link
Member Author

Ready for review

@marek-safar
Copy link
Contributor

@vargaz please review

/* only valid on interface methods*/
/* method is marked "virtual" but not "virtual abstract" */
return method->flags & method->flags & METHOD_ATTRIBUTE_VIRTUAL && !(method->flags & METHOD_ATTRIBUTE_ABSTRACT);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some accessors like m_method_is_virtual () etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong.

@vargaz do you mean not using the accessor is wrong, or checking for a default interface method using the method flags is wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part:
method->flags & method->flags & METHOD_ATTRIBUTE_VIRTUAL

@lambdageek
Copy link
Member Author

/azp run sync-runtime-to-mono

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lambdageek lambdageek merged commit 4e03f36 into dotnet:main Jun 15, 2021
lambdageek added a commit to lambdageek/mono that referenced this pull request Jun 15, 2021
…ses, or classes using DIMs

If the interface method is reabstracted, and either the found implementation
method is abstract, or the found implementation method is from another
DIM (meaning neither klass nor any of its ancestor classes implemented the
method), then say the target method is null. Otherwise return the found
implementation method, even if it is abstract.

Corresponding dotnet/runtime PR is dotnet/runtime#53972

Fixes dotnet/runtime#53933
lambdageek added a commit to mono/mono that referenced this pull request Jun 21, 2021
…ses, or classes using DIMs (#21112)

* Don't return null target methods in GetInterfaceMap for abstract classes, or classes using DIMs

If the interface method is reabstracted, and either the found implementation
method is abstract, or the found implementation method is from another
DIM (meaning neither klass nor any of its ancestor classes implemented the
method), then say the target method is null. Otherwise return the found
implementation method, even if it is abstract.

Corresponding dotnet/runtime PR is dotnet/runtime#53972

Fixes dotnet/runtime#53933

* Add method flags accessors; cleanup interface map code

Ported from dotnet/runtime#54271
bholmes added a commit to Unity-Technologies/mono that referenced this pull request Jul 1, 2021
…ses, or classes using DIMs (mono#21112)

* Don't return null target methods in GetInterfaceMap for abstract classes, or classes using DIMs

If the interface method is reabstracted, and either the found implementation
method is abstract, or the found implementation method is from another
DIM (meaning neither klass nor any of its ancestor classes implemented the
method), then say the target method is null. Otherwise return the found
implementation method, even if it is abstract.

Corresponding dotnet/runtime PR is dotnet/runtime#53972

Fixes dotnet/runtime#53933

* Add method flags accessors; cleanup interface map code

Ported from dotnet/runtime#54271
@ghost ghost locked as resolved and limited conversation to collaborators Jul 16, 2021
@lambdageek lambdageek deleted the fix-gh-53933 branch March 19, 2022 16:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MonoVM: Type.GetInterfaceMap may return null TargetMethods entries
3 participants