-
Notifications
You must be signed in to change notification settings - Fork 5.1k
TypedByReference should be treated as a normal valuetype for calling convention purposes #71675
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// This test is covering an issue where we would incorrectly compute the | ||
// argument layout of the static method delegate thunk, due to an issue | ||
// where we failed to handle ELEMENT_TYPE_TYPEDBYREF like the valuetype it is. | ||
// This would not reproduce only Windows X64 due to the particular abi of that | ||
// platform, but was found on Unix X64. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
public class Test11611 | ||
{ | ||
struct TestStruct | ||
{ | ||
public int a; | ||
public int b; | ||
} | ||
|
||
|
||
public delegate void testDelegate(TypedReference tr); | ||
public static testDelegate d; | ||
|
||
static void test(TypedReference tr) | ||
{ | ||
Type t = __reftype(tr); | ||
Console.WriteLine($"tr = {t.Name}"); | ||
} | ||
public static void Test() | ||
{ | ||
TestStruct s = default; | ||
var tr = __makeref(s); | ||
test(tr); | ||
d(tr); // this will crash due to __reftype(tr) | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static int Main(string[] args) | ||
{ | ||
Console.WriteLine("About to run test"); | ||
d = test; | ||
Test(); | ||
Console.WriteLine("Test complete run test"); | ||
return 100; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/tests/Regressions/coreclr/GitHub_42732/test42732.csproj
This file contains hidden or 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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<CLRTestPriority>1</CLRTestPriority> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="test42732.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> | ||
</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 don't think this test is appropriate. The github number thing here makes sense with the JIT tests, but not with defined behaviors. I'd prefer to see this test added to an existing collection for
TypedReference
undersrc/tests/Loader/classloader
or, since this is pure managed, inTypedReferenceTests.cs
.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.
Reasonable. I originally put the test here, as I guessed it was weird optimizer thing.... as it was only reproducing on Linux then I looked a bit deeper.
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.
Instead of moving this, I'd also be fine with clearly documenting in the test the state we are validating here.