Skip to content

Use TypedReference as argument with a delegate will crash #42732

@jeffgoku

Description

@jeffgoku

Description

when use TypedReference as argument with a delegate will crash.

using System;

public class Program
{
	struct TestStruct
	{
		public int a;
		public int b;
	}

	delegate void testDelegate(TypedReference tr);

	static void test(TypedReference tr)
	{
		Type t = __reftype(tr);
		Console.WriteLine($"tr = {t.Name}");
	}
	public static void Main(string[] args)
	{
		TestStruct s = default;
		var tr = __makeref(s);

		test(tr);

		testDelegate d = test;
		d(tr); // this will crash due to __reftype(tr)
	}
}

Configuration

I tested this with .NET core 3.1 and 5.0-rc1 in Mac and Ubuntu 20.04 LTS, both will crash. But this works for Mono. This also works in Windows.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions