diff options
author | Lubomir Litchev <lubol@microsoft.com> | 2016-04-10 13:46:01 -0700 |
---|---|---|
committer | Lubomir Litchev <lubol@microsoft.com> | 2016-04-10 13:46:01 -0700 |
commit | e2637731b980a6d73c5bb244720f4a5931001727 (patch) | |
tree | 3110486ad67c963120e6cbdcef09f162bcf902e8 | |
parent | ac2ffdd6c7dd23043c111e010298713c12aecbe4 (diff) | |
download | coreclr-e2637731b980a6d73c5bb244720f4a5931001727.tar.gz coreclr-e2637731b980a6d73c5bb244720f4a5931001727.tar.bz2 coreclr-e2637731b980a6d73c5bb244720f4a5931001727.zip |
Add a test for Issue 4147.
This checkin adds a test for Issue 4147.
4 files changed, 259 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_4115/GitHub_4115.cs b/tests/src/JIT/Regression/JitBlue/GitHub_4115/GitHub_4115.cs new file mode 100644 index 0000000000..bfe14cc037 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_4115/GitHub_4115.cs @@ -0,0 +1,146 @@ +// 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. + +// This test could fail in GCStress=0xC case, if the object movement happens at the right place and time. +// If the GC guarantees object movement at every collection, the case will fail in that GC stress mode always. +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; + +namespace Issue_4115 +{ + public class MyClass + { + private GCHandle _pinHandle; + private IntPtr _dataArrayPtr; + public ArraySegment<byte> Data; + public MyClass() + { + } + + public object Obj { get; private set; } + public byte[] Array => Data.Array; + public int Start { get; set; } + public int End { get; set; } + public MyClass Next { get; set; } + } + + public struct MyIterator + { + private static readonly int _vectorSpan = 100; + + private MyClass _class; + + private int _index; + + public bool IsDefault + { + get + { + return this._class == null; + } + } + + public bool IsEnd + { + get + { + if (this._class == null) { + return true; + } + if (this._index < this._class.End) { + return false; + } + for (MyClass next = this._class.Next; next != null; next = next.Next) { + if (next.Start < next.End) { + return false; + } + } + return true; + } + } + + public MyClass Class + { + get + { + return this._class; + } + } + + public int Index + { + get + { + return this._index; + } + } + + public MyIterator(MyClass clazz) + { + this._class = clazz; + MyClass expr_0E = this._class; + this._index = ((expr_0E != null) ? expr_0E.Start : 0); + } + + public MyIterator(MyClass clazz, int index) + { + this._class = clazz; + this._index = index; + } + } + + public class MainClass + { + private readonly object _returnLock = new object(); + + private MyClass _head; + private MyClass _tail; + private MyIterator _lastStart; + + public MyIterator TestMethod() + { + lock (_returnLock) + { + if (_tail == null) + { + return default(MyIterator); + } + + // In this assignment there could be a GC hole: + // gcrReg -[rbx] + // byrReg +[rbx] + // add rbx, 32 + // mov r15, rbx <--- r15 is not tracked to have a byref pointer. + // If a GC happens between this instruction and the next one, we have an invalid pointer. + // gcrReg -[rdi] + // byrReg +[rdi] + // mov rdi, r15 + // New gcrReg live regs = 00000000 { } + + _lastStart = new MyIterator(_tail, _tail.End); + return _lastStart; + } + } + + static int Main(string[] args) + { + MainClass mainClass = new MainClass(); + mainClass._head = mainClass._tail = new MyClass(); + mainClass._head.End = 4; + if (mainClass.TestMethod().Class.End == 4) + { + Console.WriteLine("Passed"); + return 100; + } + else + { + Console.WriteLine("Failed"); + return 1; + } + } + } +}
\ No newline at end of file diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_4115/GitHub_4115.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_4115/GitHub_4115.csproj new file mode 100644 index 0000000000..23bd109fc0 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_4115/GitHub_4115.csproj @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + <DebugType></DebugType> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(MSBuildProjectName).cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <PropertyGroup> + <ProjectJson>project.json</ProjectJson> + <ProjectLockJson>project.lock.json</ProjectLockJson> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project> diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_4115/app.config b/tests/src/JIT/Regression/JitBlue/GitHub_4115/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_4115/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_4115/project.json b/tests/src/JIT/Regression/JitBlue/GitHub_4115/project.json new file mode 100644 index 0000000000..f084fdaed9 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_4115/project.json @@ -0,0 +1,36 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-rc2-23816", + "System.Collections.Specialized": "4.0.1-rc2-23816", + "System.ComponentModel": "4.0.1-rc2-23816", + "System.Console": "4.0.0-rc2-23816", + "System.Diagnostics.Process": "4.1.0-rc2-23816", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-rc2-23816", + "System.Linq.Queryable": "4.0.1-rc2-23816", + "System.Reflection": "4.1.0-rc2-23816", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.1.0-rc2-23816", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.1.0-rc2-23816", + "System.Runtime.Loader": "4.0.0-rc2-23816", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Thread": "4.0.0-rc2-23816", + "System.Threading.ThreadPool": "4.0.10-rc2-23816", + "System.Xml.ReaderWriter": "4.0.11-rc2-23816", + "System.Xml.XDocument": "4.0.11-rc2-23816", + "System.Xml.XmlDocument": "4.0.1-rc2-23816", + "System.Xml.XmlSerializer": "4.0.11-rc2-23816" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file |