summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorEgor Chesakov <Egor.Chesakov@microsoft.com>2019-06-05 16:24:12 -0700
committerGitHub <noreply@github.com>2019-06-05 16:24:12 -0700
commit10df20ed3ff0208b3f16f79d5062662a8827f579 (patch)
tree43d2a1e58fd64960a96f6328b5fa42e40152122a /tests/src
parenta64cb0a41a4ebeb4a61b8b0f1f2eeeff8dd539c9 (diff)
downloadcoreclr-10df20ed3ff0208b3f16f79d5062662a8827f579.tar.gz
coreclr-10df20ed3ff0208b3f16f79d5062662a8827f579.tar.bz2
coreclr-10df20ed3ff0208b3f16f79d5062662a8827f579.zip
Zero initReg in genSetGSSecurityCookie (#24371)
Fix an issue that is reproduced when 1) a register is used in the prolog for initializing GSSecurityCookie (i.e. the register contains a random non-zero value) and 2) the same register holds a must-init GC variable in the next basic block and 3) the variable is live at the beginning of this basic block. The register was not zeroed at the end of the prolog and this was causing segmentation fault during GC.Collect().
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_24278/GitHub_24278.il67
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_24278/GitHub_24278.ilproj24
2 files changed, 91 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24278/GitHub_24278.il b/tests/src/JIT/Regression/JitBlue/GitHub_24278/GitHub_24278.il
new file mode 100644
index 0000000000..e20cc03a79
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_24278/GitHub_24278.il
@@ -0,0 +1,67 @@
+// 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.
+
+.assembly extern System.Runtime { }
+.assembly GitHub_24278 { }
+.module GitHub_24278.exe
+
+// GitHub 24278: a bug is reproduced when
+// 1) a register is used in the prolog for initializing GSSecurityCookie (i.e. the register contains a random non-zero value) and
+// 2) the same register holds a must-init GC variable in the next basic block and
+// 3) the variable is live at the beginning of this basic block.
+// The register was not zeroed at the end of the prolog and this was causing segmentation fault during GC.Collect().
+//
+// This happens in MainMethod at IL_0013:
+// V_0 is not initialized by IL instructions of one of the path to IL_0013 and must be zeroed in the prolog since it is live at IL_0013.
+
+.class private auto ansi beforefieldinit GitHub_24278.Program
+ extends [System.Runtime]System.Object
+{
+ .method private hidebysig static bool True() cil managed noinlining
+ {
+ // Code size 2 (0x2)
+ .maxstack 8
+ IL_0000: ldc.i4.1
+ IL_0001: ret
+ } // end of method Program::True
+
+ .method private hidebysig static void Use(int32 arg0) cil managed noinlining
+ {
+ // Code size 6 (0x6)
+ .maxstack 8
+ IL_0000: call void [System.Runtime]System.GC::Collect()
+ IL_0005: ret
+ } // end of method Program::Use
+
+ .method private hidebysig static void MainMethod() cil managed noinlining
+ {
+ //
+ .maxstack 1
+ .locals init (object V_0)
+ IL_0000: call bool GitHub_24278.Program::True()
+ IL_0005: brtrue.s IL_000d
+
+ IL_0007: newobj instance void [System.Runtime]System.Object::.ctor()
+ IL_000c: stloc.0
+ IL_000d: ldc.i4.s 32
+ IL_000f: conv.u
+ IL_0010: localloc
+ IL_0012: ldind.i4
+ IL_0013: call void GitHub_24278.Program::Use(int32)
+ IL_0018: ldloc.0
+ IL_0019: call void [System.Runtime]System.GC::KeepAlive(object)
+ IL_001e: ret
+ } // end of method Program::MainMethod
+
+ .method private hidebysig static int32
+ Main(string[] args) cil managed
+ {
+ .entrypoint
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: call void GitHub_24278.Program::MainMethod()
+ IL_0005: ldc.i4.s 100
+ IL_0007: ret
+ } // end of method Program::Main
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24278/GitHub_24278.ilproj b/tests/src/JIT/Regression/JitBlue/GitHub_24278/GitHub_24278.ilproj
new file mode 100644
index 0000000000..506f235e2f
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_24278/GitHub_24278.ilproj
@@ -0,0 +1,24 @@
+<?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>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="GitHub_24278.il" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>