-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[release/10.0] [mono][interp] Fix miscompile of self-assignment via newobj with alised byref args. (#131586) #131927
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
Open
lateralusX
wants to merge
1
commit into
dotnet:release/10.0
Choose a base branch
from
lateralusX:backport/131586-to-release/10.0
base: release/10.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−1
Open
Changes from all commits
Commits
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
70 changes: 70 additions & 0 deletions
70
src/tests/JIT/Regression/JitBlue/Runtime_122237/Runtime_122237.cs
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,70 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Runtime_122237; | ||
|
|
||
| using Xunit; | ||
|
|
||
| // Self-reassignment through a constructor whose `in` (byref) parameters alias the | ||
| // destination: `a = new GEJ(a.x, a.y, a.z, a.infinity)`. Per the ECMA-335 semantics of | ||
| // `newobj`, the object must be constructed into a temporary and only then copied to `a`, | ||
| // so the constructor observes the *old* value of `a` through the `in` pointers. A copy | ||
| // elimination that forwards the constructed value directly into the address-taken `a` | ||
| // would make the constructor read the storage it is simultaneously writing, zeroing the | ||
| // fields. The loop runs long enough to reach the Mono interpreter's optimized tier. | ||
| public readonly struct FE | ||
| { | ||
| public readonly uint n0, n1, n2, n3, n4, n5, n6, n7, n8, n9; | ||
| public readonly int magnitude; | ||
| public readonly bool normalized; | ||
|
|
||
| public FE(uint a0, uint a1, uint a2, uint a3, uint a4, uint a5, uint a6, uint a7, uint a8, uint a9) | ||
| { | ||
| n0 = a0; n1 = a1; n2 = a2; n3 = a3; n4 = a4; | ||
| n5 = a5; n6 = a6; n7 = a7; n8 = a8; n9 = a9; | ||
| magnitude = 1; | ||
| normalized = true; | ||
| } | ||
| } | ||
|
|
||
| public readonly struct GEJ | ||
| { | ||
| public readonly FE x, y, z; | ||
| public readonly bool infinity; | ||
|
|
||
| public GEJ(in FE x, in FE y, in FE z, bool infinity) | ||
| { | ||
| this.x = x; | ||
| this.y = y; | ||
| this.z = z; | ||
| this.infinity = infinity; | ||
| } | ||
| } | ||
|
|
||
| public class Runtime_122237 | ||
| { | ||
| [Fact] | ||
| public static void TestEntryPoint() | ||
| { | ||
| var a = new GEJ( | ||
| new FE(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), | ||
| new FE(11, 22, 33, 44, 55, 66, 77, 88, 99, 11), | ||
| new FE(21, 22, 23, 24, 25, 26, 27, 28, 29, 210), | ||
| false); | ||
|
|
||
| uint expected = a.x.n0; | ||
|
|
||
| int firstBad = -1; | ||
| for (int i = 0; i < 5000; i++) | ||
| { | ||
| a = new GEJ(a.x, a.y, a.z, a.infinity); | ||
| if (a.x.n0 != expected) | ||
| { | ||
| firstBad = i; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| Assert.Equal(-1, firstBad); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/tests/JIT/Regression/JitBlue/Runtime_122237/Runtime_122237.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,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <Optimize>True</Optimize> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="$(MSBuildProjectName).cs" /> | ||
| </ItemGroup> | ||
| </Project> |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.