summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2020-01-14 10:35:50 -0800
committerAnirudh Agnihotry <anirudhagnihotry098@gmail.com>2020-01-14 10:35:50 -0800
commit0402229da18652194566372993f46e29c7125443 (patch)
treebff117fc3e60c933f74fe7e9c0cbc680d3f96159 /tests
parent942f3ac191bfd8cfae52b8675d6ebdaea43149c7 (diff)
downloadcoreclr-0402229da18652194566372993f46e29c7125443.tar.gz
coreclr-0402229da18652194566372993f46e29c7125443.tar.bz2
coreclr-0402229da18652194566372993f46e29c7125443.zip
Release/3.1 port of dotnet/runtime#239 (#27973)
Fix for #27923 The jit might fail to locate a class handle for a ref class, leading to an unexpected crash while jitting. ## Customer Impact Unexpected and hard to diagnose crash/exception ## Regression? Yes, introduced during the development 3.0 cycle. 2.x behaves correctly. ## Testing Verified the user's test case now passes; no diffs seen in any existing framework or test code. ## Risk **Low**: the jit will now fall back to using the handle for System.Object if no better option can be found. cc @BruceForstall ____ In some cases we may end up in lvaSetClass without a valid ref class handle from either the IR or the stack. Use the handle for object as a conservative fallback.
Diffstat (limited to 'tests')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_27923/GitHub_27923.cs34
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_27923/GitHub_27923.csproj34
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_27923/GitHub_27923.cs b/tests/src/JIT/Regression/JitBlue/GitHub_27923/GitHub_27923.cs
new file mode 100644
index 0000000000..9ac2283299
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_27923/GitHub_27923.cs
@@ -0,0 +1,34 @@
+// 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.Runtime.CompilerServices;
+
+class Writer
+{
+ public object Data { get; set; }
+ public int Position { get; set; }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ Writer()
+ {
+ Data = new int[] { 100, -1, -2, -3 };
+ Position = 4;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static ArraySegment<byte> Test()
+ {
+ var writer = new Writer();
+ object temp = writer.Data;
+ byte[] data = Unsafe.As<object, byte[]>(ref temp);
+ return new ArraySegment<byte>(data, 0, writer.Position);
+ }
+
+ public static int Main()
+ {
+ var x = Test();
+ return x[0];
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_27923/GitHub_27923.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_27923/GitHub_27923.csproj
new file mode 100644
index 0000000000..95aba995a2
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_27923/GitHub_27923.csproj
@@ -0,0 +1,34 @@
+<?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>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>