-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[mono] Fix StackTrace from a dim and Vtable offsets for static interface method #60770
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b8b3e59
Fix mono_get_generic_context_from_stack_frame when it's from a dim.
thaystg f2007dc
Using @vargaz fix
thaystg e9eec2c
Fixing test case source name
thaystg ee3654f
Fix behavior when the interface had static interface methods.
thaystg 33ad356
Fixing test cases.
thaystg 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
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
190 changes: 190 additions & 0 deletions
190
src/tests/Loader/classloader/DefaultInterfaceMethods/regressions/github60486.cs
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,190 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
public interface IPublisher<out TData> | ||
{ | ||
event Action<TData> OnPublish; | ||
} | ||
|
||
public interface TestItf1<TT> | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestMethod1(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
StackFrame.Validate(Environment.StackTrace, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestMethod2(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod3(this, publisher, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
protected static void TestMethod3(TestItf1<TT> subscriber, IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
StackFrame.Validate(Environment.StackTrace, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestMethod4(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod3(this, publisher, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestMethod5(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod3(this, publisher, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestMethod10(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod3(this, publisher, expectedFrames); | ||
} | ||
|
||
void TestMethod11(IPublisher<TT> publisher, StackFrame[] expectedFrames); | ||
} | ||
|
||
public interface TestItf2<TT> : TestItf1<TT> | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestItf1<TT>.TestMethod5(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod3(this, publisher, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestItf1<TT>.TestMethod10(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod3(this, publisher, expectedFrames); | ||
} | ||
} | ||
|
||
public interface TestItf3<TT> : TestItf1<TT> | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestMethod6(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod3(this, publisher, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestMethod7(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod8(this, publisher, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
protected static void TestMethod8(TestItf1<TT> subscriber, IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
StackFrame.Validate(Environment.StackTrace, expectedFrames); | ||
} | ||
|
||
void TestMethod9(IPublisher<TT> publisher, StackFrame[] expectedFrames); | ||
} | ||
|
||
public interface TestItf4<TT> : TestItf3<TT> | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
void TestItf3<TT>.TestMethod9(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestMethod8(this, publisher, expectedFrames); | ||
} | ||
} | ||
|
||
public class ProgramBase<TT> : TestItf4<TT> | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public void TestMethod10(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestItf1<TT>.TestMethod3(this, publisher, expectedFrames); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public void TestMethod11(IPublisher<TT> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestItf1<TT>.TestMethod3(this, publisher, expectedFrames); | ||
} | ||
} | ||
|
||
public class Program : ProgramBase<InputData>, TestItf2<InputData> | ||
{ | ||
static int Main(string[] args) | ||
{ | ||
new Program().Start(); | ||
return 100; | ||
} | ||
|
||
public void Start() | ||
{ | ||
var t1 = this as TestItf1<InputData>; | ||
t1.TestMethod1(null, new[] { new StackFrame("TestItf1`1", "TestMethod1") }); | ||
t1.TestMethod2(null, new[] { new StackFrame("TestItf1`1", "TestMethod3"), new StackFrame("TestItf1`1", "TestMethod2") }); | ||
t1.TestMethod4(null, new[] { new StackFrame("TestItf1`1", "TestMethod3"), new StackFrame("Program", "TestMethod4") }); | ||
t1.TestMethod5(null, new[] { new StackFrame("TestItf1`1", "TestMethod3"), new StackFrame(new[] { "TestItf2`1", "TestItf1" }, "TestMethod5") }); | ||
|
||
var t3 = this as TestItf3<InputData>; | ||
t3.TestMethod6(null, new[] { new StackFrame("TestItf1`1", "TestMethod3"), new StackFrame("TestItf3`1", "TestMethod6") }); | ||
t3.TestMethod7(null, new[] { new StackFrame("TestItf3`1", "TestMethod8"), new StackFrame("TestItf3`1", "TestMethod7") }); | ||
t3.TestMethod9(null, new[] { new StackFrame("TestItf3`1", "TestMethod8"), new StackFrame(new[] { "TestItf4`1", "TestItf3" }, "TestMethod9") }); | ||
|
||
t1.TestMethod10(null, new[] { new StackFrame("TestItf1`1", "TestMethod3"), new StackFrame("ProgramBase`1", "TestMethod10") }); | ||
t1.TestMethod11(null, new[] { new StackFrame("TestItf1`1", "TestMethod3"), new StackFrame("ProgramBase`1", "TestMethod11") }); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public void TestMethod4(IPublisher<InputData> publisher, StackFrame[] expectedFrames) | ||
{ | ||
TestItf1<InputData>.TestMethod3(this, publisher, expectedFrames); | ||
} | ||
} | ||
|
||
public class InputData | ||
{ | ||
public int i; | ||
} | ||
|
||
public class StackFrame | ||
{ | ||
public string [] ClassName { get; set; } | ||
public string MethodName { get; set; } = string.Empty; | ||
|
||
public StackFrame(string [] className, string methodName) | ||
{ | ||
ClassName = className; | ||
MethodName = methodName; | ||
} | ||
|
||
public StackFrame(string className, string methodName) | ||
{ | ||
ClassName = new string[] { className }; | ||
MethodName = methodName; | ||
} | ||
|
||
public static void Validate(string testStack, StackFrame[] expectedFrames) | ||
{ | ||
int index = 1; | ||
|
||
string[] lines = testStack.Split( | ||
new string[] { Environment.NewLine }, | ||
StringSplitOptions.None | ||
); | ||
|
||
//Console.WriteLine(testStack); | ||
|
||
foreach (var frame in expectedFrames) | ||
{ | ||
var line = lines[index++].Trim(); | ||
|
||
|
||
if (!line.StartsWith($"at {frame.ClassName[0]}") || !line.Contains($".{frame.MethodName}") || (frame.ClassName.Length > 1 && !line.Contains($".{frame.ClassName[1]}"))) | ||
{ | ||
Console.WriteLine($"Expected {frame.ClassName}.{frame.MethodName} but got {line}"); | ||
Console.WriteLine(testStack); | ||
Environment.Exit(1); | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/tests/Loader/classloader/DefaultInterfaceMethods/regressions/github60486.csproj
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"> | ||
<PropertyGroup> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<OutputType>Exe</OutputType> | ||
<CLRTestKind>BuildAndRun</CLRTestKind> | ||
<CLRTestPriority>0</CLRTestPriority> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</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.
We're going to need to revisit this (and line 1535, below) when non-abstract static virtual methods are going to be supported