Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 54f1cf6

Browse files
authored
Port to 1.0.0 - Fix passing struct with four floats in registers via reflection (#14392)
* Port to 1.0.0 - Fix passing struct with four floats in registers via reflection This change fixes a bug in the code that copies a struct into the transition frame. When it contains four floats, the first two are put to the right place, but the following two are placed to an address that's offset by 8 instead of by 16. It also adds regression test for this problem as Pri 1 test. * Add missing project.json and app.config
1 parent d695a89 commit 54f1cf6

File tree

5 files changed

+168
-1
lines changed

5 files changed

+168
-1
lines changed

src/vm/argdestination.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class ArgDestination
136136
_ASSERTE(eightByteSize == 4);
137137
*(UINT32*)floatRegDest = *(UINT32*)src;
138138
}
139-
floatRegDest += 8;
139+
floatRegDest += 16;
140140
}
141141
else
142142
{
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{E55A6F8B-B9E3-45CE-88F4-22AE70F606CB}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<FileAlignment>512</FileAlignment>
12+
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
13+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
14+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
15+
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
16+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
17+
<ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
18+
<CLRTestKind>BuildAndRun</CLRTestKind>
19+
<CLRTestPriority>1</CLRTestPriority>
20+
</PropertyGroup>
21+
<!-- Default configurations to help VS understand the configurations -->
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
</PropertyGroup>
26+
<ItemGroup>
27+
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
28+
<Visible>False</Visible>
29+
</CodeAnalysisDependentAssemblyPaths>
30+
</ItemGroup>
31+
<ItemGroup>
32+
<!-- Add Compile Object Here -->
33+
<Compile Include="test7685.cs" />
34+
</ItemGroup>
35+
<ItemGroup>
36+
<None Include="app.config" />
37+
<None Include="project.json" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
44+
</ItemGroup>
45+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
46+
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
47+
</PropertyGroup>
48+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
8+
</dependentAssembly>
9+
<dependentAssembly>
10+
<assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
11+
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
12+
</dependentAssembly>
13+
<dependentAssembly>
14+
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
15+
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
16+
</dependentAssembly>
17+
<dependentAssembly>
18+
<assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
19+
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
20+
</dependentAssembly>
21+
<dependentAssembly>
22+
<assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
23+
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
24+
</dependentAssembly>
25+
</assemblyBinding>
26+
</runtime>
27+
</configuration>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"dependencies": {
3+
"Microsoft.NETCore.Platforms": "1.0.1-rc3-24117-00",
4+
"System.Collections": "4.0.10",
5+
"System.Collections.NonGeneric": "4.0.1-rc3-24117-00",
6+
"System.Collections.Specialized": "4.0.1-rc3-24117-00",
7+
"System.ComponentModel": "4.0.1-rc3-24117-00",
8+
"System.Console": "4.0.0-rc3-24117-00",
9+
"System.Diagnostics.Process": "4.1.0-rc3-24117-00",
10+
"System.Globalization": "4.0.10",
11+
"System.Globalization.Calendars": "4.0.0",
12+
"System.IO": "4.0.10",
13+
"System.IO.FileSystem": "4.0.1-rc3-24117-00",
14+
"System.IO.FileSystem.Primitives": "4.0.0",
15+
"System.Linq": "4.1.0-rc3-24117-00",
16+
"System.Linq.Queryable": "4.0.1-rc3-24117-00",
17+
"System.Reflection": "4.1.0-rc3-24117-00",
18+
"System.Reflection.Primitives": "4.0.0",
19+
"System.Runtime": "4.1.0-rc3-24117-00",
20+
"System.Runtime.Extensions": "4.0.10",
21+
"System.Runtime.Handles": "4.0.0",
22+
"System.Runtime.InteropServices": "4.1.0-rc3-24117-00",
23+
"System.Runtime.Loader": "4.0.0-rc3-24117-00",
24+
"System.Text.Encoding": "4.0.10",
25+
"System.Threading": "4.0.10",
26+
"System.Threading.Thread": "4.0.0-rc3-24117-00",
27+
"System.Xml.ReaderWriter": "4.0.11-rc3-24117-00",
28+
"System.Xml.XDocument": "4.0.11-rc3-24117-00",
29+
"System.Xml.XmlDocument": "4.0.1-rc3-24117-00",
30+
"System.Xml.XmlSerializer": "4.0.11-rc3-24117-00"
31+
},
32+
"frameworks": {
33+
"dnxcore50": {}
34+
},
35+
"runtimes": {
36+
"win7-x86": {},
37+
"win7-x64": {},
38+
"ubuntu.14.04-x64": {},
39+
"osx.10.10-x64": {},
40+
"centos.7-x64": {},
41+
"rhel.7-x64": {},
42+
"debian.8-x64": {}
43+
}
44+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
using System;
5+
using System.Reflection;
6+
7+
public class Test7685
8+
{
9+
static RectangleF argumentInDStuff;
10+
11+
public static int Main()
12+
{
13+
int iRetVal = 100;
14+
15+
var r = new RectangleF(1.2f, 3.4f, 5.6f, 7.8f);
16+
typeof(Test7685).GetTypeInfo().GetDeclaredMethod("DoStuff").Invoke(null, new object[] { r });
17+
18+
if (!RectangleF.Equals(ref argumentInDStuff, ref r))
19+
{
20+
TestLibrary.Logging.WriteLine($"Error: passing struct with floats via reflection. Callee received {argumentInDStuff} instead of {r}");
21+
iRetVal = 0;
22+
}
23+
24+
return iRetVal;
25+
}
26+
27+
public static void DoStuff(RectangleF r)
28+
{
29+
argumentInDStuff = r;
30+
}
31+
}
32+
33+
public struct RectangleF
34+
{
35+
private float _x, _y, _width, _height;
36+
37+
public RectangleF(float x, float y, float width, float height)
38+
{
39+
_x = x; _y = y; _width = width; _height = height;
40+
}
41+
42+
public static bool Equals(ref RectangleF r1, ref RectangleF r2)
43+
{
44+
return (r2._x == r1._x) && (r2._y == r1._y) && (r2._width == r1._width) && (r2._height == r1._height);
45+
}
46+
47+
public override string ToString() => $"[{_x}, {_y}, {_width}, {_height}]";
48+
}

0 commit comments

Comments
 (0)