-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
NativeAOT is crashing on static interface method #90333
Comments
dotnet-issue-labeler
bot
added
the
needs-area-label
An area label is needed to ensure this gets routed to the appropriate area owners
label
Aug 10, 2023
jkotas
added
area-NativeAOT-coreclr
and removed
needs-area-label
An area label is needed to ensure this gets routed to the appropriate area owners
labels
Aug 10, 2023
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsDescriptionOn .NET 8 Preview 7. Repro: using System.Diagnostics.CodeAnalysis;
using System.Reflection;
IUnknown obj = new Impl();
if (obj.QueryInterface<IBar>(out var bar)) bar.Bar();
if (obj.QueryInterface<IFoo>(out var foo)) foo.Foo();
interface IComInterface
{
abstract static Guid IID { get; }
}
interface IUnknown : IComInterface
{
static Guid IComInterface.IID => new("00000000-0000-0000-C000-000000000046");
static Guid GetIID<TVtbl>() where TVtbl : IComInterface => TVtbl.IID;
[UnconditionalSuppressMessage("ILLink", "IL2111")]
[UnconditionalSuppressMessage("ILLink", "IL2075")]
bool QueryInterface<
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces | DynamicallyAccessedMemberTypes.NonPublicProperties)] T
>([NotNullWhen(true)] out T? result) where T : IComInterface
{
foreach (var p in GetType()
.GetInterfaces()
.SelectMany(([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicProperties)] i)
=> i.GetProperty("IComInterface.IID", BindingFlags.NonPublic | BindingFlags.Static)
is PropertyInfo propertyInfo ? [propertyInfo] : Array.Empty<PropertyInfo>()))
{
if (p.GetValue(this) is Guid guid && guid == GetIID<T>())
{
result = (T)this;
return true;
}
}
result = default;
return false;
}
}
interface IFoo : IComInterface, IUnknown
{
static Guid IComInterface.IID => new("12345678-1234-1234-1234-1234567890AB");
void Foo();
}
interface IBar : IComInterface, IUnknown
{
static Guid IComInterface.IID => new("12345678-1234-1234-1234-1234567890CD");
void Bar();
}
interface IBaz : IComInterface, IFoo, IBar
{
static Guid IComInterface.IID => new("12345678-1234-1234-1234-1234567890EF");
}
partial struct Impl : IBaz
{
public void Foo() => Console.WriteLine("foo");
public void Bar() => Console.WriteLine("bar");
} Reproduction StepsBuild the source with NativeAOT and run it. Expected behaviorNo crashing. Actual behaviorCrashing. Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
Static interface methods |
jkotas
changed the title
NativeAOT is crashing on PropertyInfo.GetValue without managed exception
NativeAOT is crashing on static interface method
Aug 10, 2023
Reduced repro: IUnknown obj = new Impl();
Console.WriteLine(obj.M<IBar>());
interface IComInterface
{
abstract static Guid IID { get; }
}
interface IUnknown : IComInterface
{
static Guid IComInterface.IID => new("00000000-0000-0000-C000-000000000046");
static Guid GetIID<TVtbl>() where TVtbl : IComInterface => TVtbl.IID;
Guid M<T>() where T : IComInterface
{
return GetIID<T>();
}
}
interface IFoo : IComInterface, IUnknown
{
static Guid IComInterface.IID => new("12345678-1234-1234-1234-1234567890AB");
}
interface IBar : IComInterface, IUnknown
{
static Guid IComInterface.IID => new("12345678-1234-1234-1234-1234567890CD");
}
interface IBaz : IComInterface, IFoo, IBar
{
static Guid IComInterface.IID => new("12345678-1234-1234-1234-1234567890EF");
}
partial struct Impl : IBaz
{
} |
Fails in debug runtime with:
|
ghost
added
the
in-pr
There is an active PR which will close this issue when it is merged
label
Aug 31, 2023
ghost
removed
the
in-pr
There is an active PR which will close this issue when it is merged
label
Sep 1, 2023
ghost
locked as resolved and limited conversation to collaborators
Oct 1, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
On .NET 8 Preview 7.
Repro:
Reproduction Steps
Build the source with NativeAOT and run it.
Expected behavior
No crashing.
Actual behavior
Crashing.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: