Beef
Beef copied to clipboard
Issue with delegates and pass-by-value on Linux
The assertion in the code below fails when:
Foohas theuint8[64]padding.Foohas the[CRepr]attribute.Foois being passed by value to Test.Testis being called through a delegate.
using System;
using System.Diagnostics;
namespace BeefCrashTest;
public static class Program
{
[CRepr]
struct Foo
{
public char8* bar;
public uint8[64] padding;
}
public static bool Test(Foo f)
{
return StringView(f.bar) == "BBBBBBBBBBBBBBB";
}
public static void Main()
{
Foo f = .() { bar = "BBBBBBBBBBBBBBB" };
delegate bool(Foo) func = scope => Test;
Debug.Assert(func(f));
}
}
Tested with: https://github.com/beefytech/Beef/commit/4c656529556ef2e7f8398be1b6c1d803dea512a6
Edit 05/06/2023: Added more information and simplified repro code.