-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for issue 70385 (stack overflow in the CoreCLR runtime during SVM validation) #71135
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4fd71b6
Regression test for recursive generics causing runtime stack overflow
trylek a650155
Adjust load levels in SVM validation to prevent infinite recursion
trylek fc8dddf
Fix C# source code per hez2010's PR feedback
trylek 08d0f4b
Address David's PR feedback
trylek 4303ac3
Fix TryResolveVirtualStaticMethodOnThisType per David's feedback
trylek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/tests/Loader/classloader/StaticVirtualMethods/RegressionTests/GitHub_70385.cs.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
interface IBase<T> | ||
{ | ||
public static abstract void Method(); | ||
} | ||
|
||
interface IDerived<T> : IBase<T> | ||
{ | ||
public static void IBase<T>.Method() | ||
{ | ||
Console.WriteLine("IDerived.Method"); | ||
} | ||
} | ||
|
||
class Final : IDerived<Final> | ||
{ | ||
} | ||
|
||
class Program | ||
{ | ||
private static void CallSVM<T, U>() | ||
where T : IBase<U> | ||
{ | ||
T.Method(); | ||
} | ||
|
||
static int Main() | ||
{ | ||
CallSVM<Final, Final>(); | ||
return 100; | ||
} | ||
} |
135 changes: 135 additions & 0 deletions
135
src/tests/Loader/classloader/StaticVirtualMethods/RegressionTests/GitHub_70385.il
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
|
||
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18408 | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
|
||
|
||
// Metadata version: v4.0.30319 | ||
.assembly extern System.Runtime | ||
{ | ||
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: | ||
.ver 7:0:0:0 | ||
} | ||
.assembly extern System.Console | ||
{ | ||
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: | ||
.ver 7:0:0:0 | ||
} | ||
.assembly RecursiveGeneric | ||
{ | ||
.custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) | ||
.custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx | ||
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. | ||
|
||
// | ||
// .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 ) | ||
|
||
.hash algorithm 0x00008004 | ||
.ver 0:0:0:0 | ||
} | ||
.module RecursiveGeneric.dll | ||
// MVID: {10541B0F-16D6-4F9A-B0EB-E793F524F163} | ||
.imagebase 0x00400000 | ||
.file alignment 0x00000200 | ||
.stackreserve 0x00100000 | ||
.subsystem 0x0003 // WINDOWS_CUI | ||
.corflags 0x00000001 // ILONLY | ||
// Image base: 0x03000000 | ||
|
||
|
||
// =============== CLASS MEMBERS DECLARATION =================== | ||
|
||
.class interface private abstract auto ansi IBase`1<T> | ||
{ | ||
.method public hidebysig static abstract virtual | ||
void Method() cil managed | ||
{ | ||
} // end of method IBase`1::Method | ||
|
||
} // end of class IBase`1 | ||
|
||
.class interface private abstract auto ansi IDerived`1<T> | ||
implements class IBase`1<!T> | ||
{ | ||
.method public hidebysig static void Method() cil managed | ||
{ | ||
.override method void class IBase`1<!T>::Method() | ||
// | ||
.maxstack 8 | ||
IL_0000: nop | ||
IL_0001: ldstr "Final.Method" | ||
IL_0006: call void [System.Console]System.Console::WriteLine(string) | ||
IL_000b: nop | ||
IL_000c: ret | ||
} // end of method Final::Method | ||
|
||
} // end of class IDerived`1 | ||
|
||
.class private auto ansi beforefieldinit Final | ||
extends [System.Runtime]System.Object | ||
implements class IDerived`1<class Final>, | ||
class IBase`1<class Final> | ||
{ | ||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
// | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: call instance void [System.Runtime]System.Object::.ctor() | ||
IL_0006: nop | ||
IL_0007: ret | ||
} // end of method Final::.ctor | ||
|
||
} // end of class Final | ||
|
||
.class private auto ansi beforefieldinit Program | ||
extends [System.Runtime]System.Object | ||
{ | ||
.method private hidebysig static void CallSVM<(class IBase`1<!!U>) T,U>() cil managed | ||
{ | ||
// | ||
.maxstack 8 | ||
IL_0000: nop | ||
IL_0001: constrained. !!T | ||
IL_0007: call void class IBase`1<!!U>::Method() | ||
IL_000c: nop | ||
IL_000d: ret | ||
} // end of method Program::CallSVM | ||
|
||
.method private hidebysig static int32 | ||
Main() cil managed | ||
{ | ||
.entrypoint | ||
// | ||
.maxstack 1 | ||
.locals init ([0] int32 V_0) | ||
IL_0000: nop | ||
IL_0001: call void Program::CallSVM<class Final,class Final>() | ||
IL_0006: nop | ||
IL_0007: ldc.i4.s 100 | ||
IL_0009: stloc.0 | ||
IL_000a: br.s IL_000c | ||
|
||
IL_000c: ldloc.0 | ||
IL_000d: ret | ||
} // end of method Program::Main | ||
|
||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
// | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: call instance void [System.Runtime]System.Object::.ctor() | ||
IL_0006: nop | ||
IL_0007: ret | ||
} // end of method Program::.ctor | ||
|
||
} // end of class Program | ||
|
||
|
||
// ============================================================= | ||
|
||
// | ||
// |
11 changes: 11 additions & 0 deletions
11
src/tests/Loader/classloader/StaticVirtualMethods/RegressionTests/GitHub_70385.ilproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.IL"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>Full</DebugType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileName).il" /> | ||
</ItemGroup> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
public
in this line is redundant and causing compilation to fail.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback, I have removed the public modifier from both interfaces in the 2nd commit. Please note that the C# code is actually not used for building the test - that's why it has the 'template' extension - because we don't yet have a Roslyn capable of compiling this code, the actual test source code is written in IL.