-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Open
Labels
area-Codegen-JIT-monoruntime-monospecific to the Mono runtimespecific to the Mono runtimeuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
Description
Creating and calling a delegate closed over null in Mono leads to runtime errors due to invalid stubs being used, see godbolt for an example.
Reproduction Steps
using System;
internal class Program
{
public static void Main()
{
Console.WriteLine(Nul());
}
public static bool Nul()
{
return new Func<bool>(new C().A).Method.CreateDelegate<Func<bool>>(null)();
}
internal class C
{
public bool A()
{
return this is null;
}
}
}Expected behavior
Prints true.
Actual behavior
Unhandled Exception:
System.InvalidProgramException: Invalid IL code in (wrapper delegate-invoke) System.Func`1<bool>:invoke_callvirt_TResult (): IL_0066: ldarga.s 1
at Program.Nul()
at Program.Main()Regression?
No idea.
Known Workarounds
Don't use Mono
Configuration
Mono main windows/linux x64
Other information
One issue I found was that Mono was incorrectly using target being null to decide the stub but even after I fixed that here, the issue was still broken.
Reactions are currently unavailable
Metadata
Metadata
Labels
area-Codegen-JIT-monoruntime-monospecific to the Mono runtimespecific to the Mono runtimeuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Type
Projects
Status
No status