From: Eugene Rozenfeld Date: Mon, 21 Mar 2016 20:52:23 +0000 (-0700) Subject: Add regression tests for two previously fixed bugs. X-Git-Tag: accepted/tizen/base/20180629.140029~5243^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1e33702da1e855a4f3fff71924bae3368d0d9b8;p=platform%2Fupstream%2Fcoreclr.git Add regression tests for two previously fixed bugs. One of the repros is in il rather than C# because the repro was sensitive to what different versions of C# compiler generated. --- diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.cs b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.cs new file mode 100644 index 0000000..a7a96b1 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.cs @@ -0,0 +1,81 @@ +// 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 Program +{ + static bool flag; + + static int Main(string[] args) + { + flag = true; + return Test(); + } + + public static int Test() + { + try + { + Repro(); + } + catch (NullReferenceException) + { + Console.WriteLine("Failure"); + return 101; + } + catch (Exception) + { + Console.WriteLine("Success"); + return 100; + } + + Console.WriteLine("Failure"); + return 101; + } + + private static void Repro() + { + string str = GetString(); + object info = null; + + if (str != null) + { + info = str.Length; + } + try + { + ThrowException(); + if (str != null) + { + Console.WriteLine(info); + } + } + catch (Exception) + { + // The bug was that the jit was removing this check causing a NullReferenceException. + if (str != null) + { + Console.WriteLine(str.Length); + } + throw; + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static void ThrowException() + { + if (flag) + { + throw new Exception(); + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static string GetString() + { + return flag ? (string) null : "test"; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.csproj b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.csproj new file mode 100644 index 0000000..215ae14 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.csproj @@ -0,0 +1,50 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages + ..\..\ + + 7a9bfb7d + + + + + + + + + False + + + + + True + + + + + + + + + + + + + $(JitPackagesConfigFileDirectory)minimal\project.json + $(JitPackagesConfigFileDirectory)minimal\project.lock.json + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150265/app.config b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/app.config new file mode 100644 index 0000000..8077c95 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/app.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.il b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.il new file mode 100644 index 0000000..9bfe429 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.il @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// This il tests importation of unbox[_any] when there are pending evaluations on the stack that side-effect +// the arguments of the unbox. + +.assembly extern mscorlib { } + +.assembly extern System.Runtime +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:1:0:0 +} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} +.assembly DevDiv_150586 +{ +} + + +.class private auto ansi beforefieldinit Bug.Program + extends [System.Runtime]System.Object +{ + .method private hidebysig static string + GetResourceString(string category, + [out] object& foundObj) cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.0 + IL_0002: box [System.Runtime]System.Boolean + IL_0007: stind.ref + IL_0008: ldstr "Hello world" + IL_000d: ldarg.0 + IL_000e: call string [System.Runtime]System.String::Concat(string, + string) + IL_0013: ret + } // end of method Program::GetResourceString + + .method private hidebysig static string + RString() cil managed + { + // Code size 38 (0x26) + .maxstack 2 + .locals init ([0] object foundObj, + [1] bool V_1) + IL_0000: ldstr "" + IL_0005: ldloca.s foundObj + IL_0007: call string Bug.Program::GetResourceString(string, + object&) + IL_000c: ldloc.0 + IL_000d: unbox.any [System.Runtime]System.Boolean + IL_0012: stloc.1 + IL_0013: ldloca.s V_1 + IL_0015: constrained. [System.Runtime]System.Boolean + IL_001b: callvirt instance string [System.Runtime]System.Object::ToString() + IL_0020: call string [System.Runtime]System.String::Concat(string, + string) + IL_0025: ret + } // end of method Program::RString + + .method private hidebysig static int32 + Main(string[] args) cil managed + { + .entrypoint + // Code size 39 (0x27) + .maxstack 1 + .locals init ([0] int32 V_0) + .try + { + IL_0000: call string Bug.Program::RString() + IL_0005: pop + IL_0006: leave.s IL_0018 + + } // end .try + catch [System.Runtime]System.Exception + { + IL_0008: pop + IL_0009: ldstr "Fail" + IL_000e: call void [System.Console]System.Console::WriteLine(string) + IL_0013: ldc.i4.s 101 + IL_0015: stloc.0 + IL_0016: leave.s IL_0025 + + } // end handler + IL_0018: ldstr "Pass" + IL_001d: call void [System.Console]System.Console::WriteLine(string) + IL_0022: ldc.i4.s 100 + IL_0024: ret + + IL_0025: ldloc.0 + IL_0026: ret + } // end of method Program::Main + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: ret + } // end of method Program::.ctor + +} // end of class Bug.Program diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.ilproj b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.ilproj new file mode 100644 index 0000000..39fd714 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.ilproj @@ -0,0 +1,44 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT .0\UITestExtensionPackages + ..\..\ + 7a9bfb7d + + + + + + + + + False + + + + None + True + + + + + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150586/app.config b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/app.config new file mode 100644 index 0000000..8077c95 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/app.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file