diff options
author | Carol Eidt <carol.eidt@microsoft.com> | 2020-02-13 14:27:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-13 14:27:49 -0800 |
commit | efcf98fc7885dc423bdf61b3423dddc63c36075f (patch) | |
tree | c39644aaa7f2e717383860b7b0eb12760e2ec3e6 /tests/src/JIT | |
parent | a86e825a641cf637d641e35f9ca88b65fe7ae801 (diff) | |
download | coreclr-efcf98fc7885dc423bdf61b3423dddc63c36075f.tar.gz coreclr-efcf98fc7885dc423bdf61b3423dddc63c36075f.tar.bz2 coreclr-efcf98fc7885dc423bdf61b3423dddc63c36075f.zip |
Port of dotnet/runtime#1059 to 3.1 branch (#27986)
This is the fix for #27924. This is a GC hole bug that was found externally, #27590.
The cause is that the JIT was using the target type of the subtract when it needed
to make a copy of the source, but it needs to use the source type.
## Customer Impact
Corruption of state that is non-deterministic and hard to track down.
## Regression?
Not a recent regression, but exposed by Unsafe.ByteOffset.
## Testing
The fix has been verified in the runtime repo.
## Risk
Low: The fix is straightfoward and only impacts 3 lines of code.
Diffstat (limited to 'tests/src/JIT')
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_27924/GitHub_27924.cs | 53 | ||||
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_27924/GitHub_27924.csproj | 46 |
2 files changed, 99 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_27924/GitHub_27924.cs b/tests/src/JIT/Regression/JitBlue/GitHub_27924/GitHub_27924.cs new file mode 100644 index 0000000000..c4b8cf5be5 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_27924/GitHub_27924.cs @@ -0,0 +1,53 @@ +// 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.Threading; +using System.Runtime.CompilerServices; +using System.Collections.Generic; +using System.Threading.Tasks; + +class Program +{ + static int returnVal = 100; + static byte[][] s = new byte[1000][]; + + static void Work() + { + for (uint i = 0; i < 1000000; i++) + { + var a = s[i++ % s.Length]; + + ref byte p = ref a[0]; + ref byte q = ref a[1]; + + if (Unsafe.ByteOffset(ref p, ref q) != new IntPtr(1)) + { + Console.WriteLine("ERROR: i = " + i); + returnVal = -1; + } + p = 1; q = 2; + } + } + + static int Main(string[] args) + { + for(int i = 0; i < s.Length; i++) s[i] = new byte[2]; + + List<Task> tasks = new List<Task>(); + for(int i = 0; i < 5; i++) + { + tasks.Add(Task.Run(Work)); + } + + Random r = new Random(); + for (uint i = 0; i < 10000; i++) + { + s[r.Next(s.Length)] = new byte[3 + r.Next(100)]; + } + Task t = Task.WhenAll(tasks); + t.Wait(); + return returnVal; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_27924/GitHub_27924.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_27924/GitHub_27924.csproj new file mode 100644 index 0000000000..155de5c4fa --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_27924/GitHub_27924.csproj @@ -0,0 +1,46 @@ +<?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> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + </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> + <AllowUnsafeBlocks>True</AllowUnsafeBlocks> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(MSBuildProjectName).cs" /> + </ItemGroup> + <PropertyGroup> + <CLRTestBatchPreCommands><![CDATA[ +$(CLRTestBatchPreCommands) +set COMPlus_GcStress=0xc +]]></CLRTestBatchPreCommands> + <BashCLRTestPreCommands><![CDATA[ +$(BashCLRTestPreCommands) +export COMPlus_GcStress=0xc +]]></BashCLRTestPreCommands> + </PropertyGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> +</Project> + |