From 640d818bc0fbc02588044fabd98cbd13c3f82e8c Mon Sep 17 00:00:00 2001 From: Vitek Karas <10670590+vitek-karas@users.noreply.github.com> Date: Mon, 12 Dec 2022 02:25:04 -0800 Subject: [PATCH] Add a test which uncovered stack overflow in 7.0 (dotnet/linker#3156) Recurisve generics with interface marking annotation used to cause stackoverflow in the linker. The test now passes since the problem was fixed in https://github.com/dotnet/linker/pull/3073 Commit migrated from https://github.com/dotnet/linker/commit/dde6d62e9e80cde5e2dd8a2ce613384ff41d4a08 --- .../DataFlow/GenericParameterDataFlow.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs index d860a1abb268d..9ccb187d288d8 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs @@ -321,6 +321,8 @@ static void TestInterfaceTypeGenericRequirements () new InterfaceImplementationTypeWithInstantiationOverSelfOnBase (); new InterfaceImplementationTypeWithOpenGenericOnBase (); new InterfaceImplementationTypeWithOpenGenericOnBaseWithRequirements (); + + RecursiveGenericWithInterfacesRequirement.Test (); } interface IGenericInterfaceTypeWithRequirements<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T> @@ -348,6 +350,23 @@ class InterfaceImplementationTypeWithOpenGenericOnBaseWithRequirements<[Dynamica { } + class RecursiveGenericWithInterfacesRequirement + { + interface IFace<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.Interfaces)] T> + { + } + + class TestType : IFace + { + } + + public static void Test () + { + var a = typeof (IFace); + var t = new TestType (); + } + } + static void TestTypeGenericRequirementsOnMembers () { // Basically just root everything we need to test