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.
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
Expected behavior
Prints
true.Actual behavior
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.