From 8e8f04af3f1a3bfeca0d80c754423412bdc1569f Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Mon, 9 Oct 2017 17:37:34 +0200 Subject: [PATCH 1/2] 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. --- src/vm/argdestination.h | 2 +- .../coreclr/GitHub_7685/Test7685.csproj | 44 +++++++++++++++++ .../coreclr/GitHub_7685/test7685.cs | 48 +++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 tests/src/Regressions/coreclr/GitHub_7685/Test7685.csproj create mode 100644 tests/src/Regressions/coreclr/GitHub_7685/test7685.cs diff --git a/src/vm/argdestination.h b/src/vm/argdestination.h index 857e596079d6..d8f6c854b223 100644 --- a/src/vm/argdestination.h +++ b/src/vm/argdestination.h @@ -136,7 +136,7 @@ class ArgDestination _ASSERTE(eightByteSize == 4); *(UINT32*)floatRegDest = *(UINT32*)src; } - floatRegDest += 8; + floatRegDest += 16; } else { diff --git a/tests/src/Regressions/coreclr/GitHub_7685/Test7685.csproj b/tests/src/Regressions/coreclr/GitHub_7685/Test7685.csproj new file mode 100644 index 000000000000..777c8dbf8d61 --- /dev/null +++ b/tests/src/Regressions/coreclr/GitHub_7685/Test7685.csproj @@ -0,0 +1,44 @@ + + + + + Debug + AnyCPU + 2.0 + {E55A6F8B-B9E3-45CE-88F4-22AE70F606CB} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages + ..\..\ + 7a9bfb7d + true + false + BuildAndRun + 1 + + + + + + + + + False + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/Regressions/coreclr/GitHub_7685/test7685.cs b/tests/src/Regressions/coreclr/GitHub_7685/test7685.cs new file mode 100644 index 000000000000..a1d35bc11c9f --- /dev/null +++ b/tests/src/Regressions/coreclr/GitHub_7685/test7685.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Reflection; + +public class Test7685 +{ + static RectangleF argumentInDStuff; + + public static int Main() + { + int iRetVal = 100; + + var r = new RectangleF(1.2f, 3.4f, 5.6f, 7.8f); + typeof(Test7685).GetTypeInfo().GetDeclaredMethod("DoStuff").Invoke(null, new object[] { r }); + + if (!RectangleF.Equals(ref argumentInDStuff, ref r)) + { + TestLibrary.Logging.WriteLine($"Error: passing struct with floats via reflection. Callee received {argumentInDStuff} instead of {r}"); + iRetVal = 0; + } + + return iRetVal; + } + + public static void DoStuff(RectangleF r) + { + argumentInDStuff = r; + } +} + +public struct RectangleF +{ + private float _x, _y, _width, _height; + + public RectangleF(float x, float y, float width, float height) + { + _x = x; _y = y; _width = width; _height = height; + } + + public static bool Equals(ref RectangleF r1, ref RectangleF r2) + { + return (r2._x == r1._x) && (r2._y == r1._y) && (r2._width == r1._width) && (r2._height == r1._height); + } + + public override string ToString() => $"[{_x}, {_y}, {_width}, {_height}]"; +} From 8bfae0935c6d80b7673462c4270eb53dacc3cd4d Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Thu, 12 Oct 2017 12:33:21 +0200 Subject: [PATCH 2/2] Add missing project.json and app.config --- .../coreclr/GitHub_7685/Test7685.csproj | 4 ++ .../coreclr/GitHub_7685/app.config | 27 ++++++++++++ .../coreclr/GitHub_7685/project.json | 44 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 tests/src/Regressions/coreclr/GitHub_7685/app.config create mode 100644 tests/src/Regressions/coreclr/GitHub_7685/project.json diff --git a/tests/src/Regressions/coreclr/GitHub_7685/Test7685.csproj b/tests/src/Regressions/coreclr/GitHub_7685/Test7685.csproj index 777c8dbf8d61..56bc99ce4f7b 100644 --- a/tests/src/Regressions/coreclr/GitHub_7685/Test7685.csproj +++ b/tests/src/Regressions/coreclr/GitHub_7685/Test7685.csproj @@ -32,6 +32,10 @@ + + + + diff --git a/tests/src/Regressions/coreclr/GitHub_7685/app.config b/tests/src/Regressions/coreclr/GitHub_7685/app.config new file mode 100644 index 000000000000..62803f59720a --- /dev/null +++ b/tests/src/Regressions/coreclr/GitHub_7685/app.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/Regressions/coreclr/GitHub_7685/project.json b/tests/src/Regressions/coreclr/GitHub_7685/project.json new file mode 100644 index 000000000000..025841ec29fc --- /dev/null +++ b/tests/src/Regressions/coreclr/GitHub_7685/project.json @@ -0,0 +1,44 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc3-24117-00", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-rc3-24117-00", + "System.Collections.Specialized": "4.0.1-rc3-24117-00", + "System.ComponentModel": "4.0.1-rc3-24117-00", + "System.Console": "4.0.0-rc3-24117-00", + "System.Diagnostics.Process": "4.1.0-rc3-24117-00", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.1-rc3-24117-00", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.1.0-rc3-24117-00", + "System.Linq.Queryable": "4.0.1-rc3-24117-00", + "System.Reflection": "4.1.0-rc3-24117-00", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.1.0-rc3-24117-00", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.1.0-rc3-24117-00", + "System.Runtime.Loader": "4.0.0-rc3-24117-00", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Thread": "4.0.0-rc3-24117-00", + "System.Xml.ReaderWriter": "4.0.11-rc3-24117-00", + "System.Xml.XDocument": "4.0.11-rc3-24117-00", + "System.Xml.XmlDocument": "4.0.1-rc3-24117-00", + "System.Xml.XmlSerializer": "4.0.11-rc3-24117-00" + }, + "frameworks": { + "dnxcore50": {} + }, + "runtimes": { + "win7-x86": {}, + "win7-x64": {}, + "ubuntu.14.04-x64": {}, + "osx.10.10-x64": {}, + "centos.7-x64": {}, + "rhel.7-x64": {}, + "debian.8-x64": {} + } +}