-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Native AOT bad code gen for constrained call #99198
Comments
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsThis looks to be a complicated set of GVMs and direct dispatches to the same interface. Works on CoreCLR, produces either a null-ref or AV with Native AOT. Core problem is that the call to
src: Console.WriteLine("Hello, World!");
var sampleJson = """
{"latestVersion":{"version":"1.6.8","artifacts":{"linux-x64":"http://localhost:64922/dnvm/dnvm.tar.gz",
"osx-x64":"http://localhost:64922/dnvm/dnvm.tar.gz","win-x64":"http://localhost:64922/dnvm/dnvm.zip"}}}
""";
var release = JsonSerializer.Deserialize<DnvmReleases>(sampleJson);
Console.WriteLine(release);
[GenerateSerde]
public partial record struct DnvmReleases(DnvmReleases.Release LatestVersion)
{
[GenerateSerde]
public partial record struct Release(
string Version,
Dictionary<string, string> Artifacts);
}
|
Reduced repro: new C<Foo<string>>().ToString();
static Type GetObject() => typeof(Foo<object>);
var s = typeof(C<>).MakeGenericType(GetObject()).GetMethod("Set").CreateDelegate<Set<Foo<object>>>();
Foo<object> ob = default;
s(ref ob);
Console.WriteLine(ob.Cookie1);
Console.WriteLine(ob.Cookie2);
delegate void Set<T>(ref T t);
interface IFoo
{
void Do<T>();
}
struct Foo<T> : IFoo
{
public nint Cookie1;
public nint Cookie2;
public void Do<T1>()
{
Cookie1 = 42;
}
}
class C<T> where T : IFoo
{
public static void Set(ref T t)
{
t.Do<T>();
}
} This is supposed to print 42 0, instead it prints 0 42. This is because we messed up the constrained call in This happens when the runtime type loader creates the dictionary - so the repro either needs some I haven't decided where the bug is. Some weird things are happening:
At minimum, it doesn't look right we allow |
This looks to be a complicated set of GVMs and direct dispatches to the same interface.
Works on CoreCLR, produces either a null-ref or AV with Native AOT. Core problem is that the call to
TryGetNextEntry
has two locations in the program: one through a GVM, and one through a constrained invocation on a struct. It appears that the constrained invocation is somehow taking the GVM path, causing an erroneous unbox node to appear that causes memory corruption.project:
src:
The text was updated successfully, but these errors were encountered: