diff options
author | Koundinya Veluri <kouvel@users.noreply.github.com> | 2018-04-03 08:49:10 -0700 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2018-04-03 17:49:10 +0200 |
commit | ee1bcc8ff0987383fdafc41e04e264b9ffb0f985 (patch) | |
tree | afbd5edb25cdcf1da4a2b953e06f561c1c182c1b /tests | |
parent | 03356bcf59b4567bfdf4070f599771b01220bd95 (diff) | |
download | coreclr-ee1bcc8ff0987383fdafc41e04e264b9ffb0f985.tar.gz coreclr-ee1bcc8ff0987383fdafc41e04e264b9ffb0f985.tar.bz2 coreclr-ee1bcc8ff0987383fdafc41e04e264b9ffb0f985.zip |
Increase crst level for ReadyToRunInfo's map lock (#17376)
Fixes regex-redux-1 failure seen in https://github.com/dotnet/coreclr/issues/15309
- HashMap lookups and insertions occur under a level 0 lock and may enter cooperative GC mode inside the lock. A GC that is triggered may delete some dynamic code, which takes another level 0 lock. It does not look like it's possible for a deadlock as a result.
- Fixed by increasing the crst level for the lock used in ReadyToRunInfo
Diffstat (limited to 'tests')
4 files changed, 192 insertions, 2 deletions
diff --git a/tests/src/CLRTest.Execute.Bash.targets b/tests/src/CLRTest.Execute.Bash.targets index 53b632b12e..a3fecb22a4 100644 --- a/tests/src/CLRTest.Execute.Bash.targets +++ b/tests/src/CLRTest.Execute.Bash.targets @@ -252,7 +252,6 @@ fi <BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun'"> <![CDATA[ -ExePath=$(InputAssemblyName) $(BashLinkerTestLaunchCmds) $(BashCLRTestLaunchCmds) if [ ! -z ${RunCrossGen+x} ]%3B then @@ -373,6 +372,8 @@ $(BashCLRTestArgPrep) $(BashCLRTestExitCodePrep) $(JitDisasmBashScript) $(IlasmRoundTripBashScript) +# Allow precommands to override the ExePath +ExePath=$(InputAssemblyName) # PreCommands $(BashCLRTestPreCommands) # Launch diff --git a/tests/src/CLRTest.Execute.Batch.targets b/tests/src/CLRTest.Execute.Batch.targets index b02c396cd4..0a6fd439a3 100644 --- a/tests/src/CLRTest.Execute.Batch.targets +++ b/tests/src/CLRTest.Execute.Batch.targets @@ -257,7 +257,6 @@ $(BatchIlrtTestLaunchCmds) ]]></BatchCLRTestLaunchCmds> <BatchCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun'"> <![CDATA[ -set ExePath=$(InputAssemblyName) $(BatchLinkerTestLaunchCmds) $(BatchCLRTestLaunchCmds) @@ -375,6 +374,9 @@ $(JitDisasmBatchScript) $(IlasmRoundTripBatchScript) +REM Allow precommands to override the ExePath +set ExePath=$(InputAssemblyName) + REM Precommands $(CLRTestBatchPreCommands) REM Launch diff --git a/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.cs b/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.cs new file mode 100644 index 0000000000..85fbf02aa6 --- /dev/null +++ b/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.cs @@ -0,0 +1,151 @@ +// 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; +using System.Reflection; +using System.Reflection.Emit; +using System.Threading; + +internal static class Program +{ + private static int Main() + { + // Verify crst levels with GCs triggered during R2R code lookup in the Prestub on the main thread, during which dynamic + // code from a background thread is deleted at the start of the GC in the main thread + + var t = new Thread(() => + { + for (uint i = 0; ; ++i) + { + DynamicMethod dynamicMethod = CreateDynamicMethod($"DynMethod{i}"); + var dynamicMethodDelegate = (Action)dynamicMethod.CreateDelegate(typeof(Action)); + dynamicMethodDelegate(); + } + }); + t.IsBackground = true; + t.Start(); + + for (int i = 0; i < 100; ++i) + { + typeof(Program).InvokeMember( + $"Func{i}", + BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Static, + null, + null, + Array.Empty<object>()); + } + + return 100; + } + + private static DynamicMethod CreateDynamicMethod(string name) + { + var dynamicMethod = new DynamicMethod(name, null, null); + ILGenerator ilGenerator = dynamicMethod.GetILGenerator(); + ilGenerator.Emit(OpCodes.Ret); + return dynamicMethod; + } + + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func0() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func1() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func2() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func3() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func4() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func5() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func6() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func7() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func8() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func9() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func10() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func11() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func12() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func13() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func14() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func15() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func16() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func17() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func18() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func19() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func20() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func21() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func22() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func23() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func24() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func25() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func26() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func27() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func28() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func29() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func30() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func31() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func32() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func33() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func34() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func35() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func36() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func37() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func38() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func39() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func40() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func41() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func42() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func43() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func44() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func45() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func46() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func47() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func48() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func49() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func50() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func51() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func52() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func53() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func54() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func55() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func56() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func57() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func58() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func59() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func60() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func61() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func62() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func63() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func64() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func65() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func66() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func67() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func68() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func69() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func70() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func71() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func72() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func73() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func74() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func75() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func76() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func77() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func78() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func79() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func80() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func81() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func82() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func83() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func84() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func85() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func86() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func87() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func88() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func89() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func90() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func91() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func92() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func93() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func94() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func95() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func96() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func97() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func98() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func99() {} +} diff --git a/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.csproj b/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.csproj new file mode 100644 index 0000000000..cce52ccb09 --- /dev/null +++ b/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.csproj @@ -0,0 +1,36 @@ +<?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> + <ProjectGuid>{8884AF49-72DA-44EC-B3E0-9FC8F9BCC1F9}</ProjectGuid> + <OutputType>Exe</OutputType> + <LangVersion>latest</LangVersion> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + </PropertyGroup> + <ItemGroup> + <Compile Include="DynamicMethodGCStress.cs" /> + </ItemGroup> + <PropertyGroup> + <CLRTestBatchPreCommands><![CDATA[ +$(CLRTestBatchPreCommands) +%CORE_ROOT%\crossgen.exe /readytorun /platform_assemblies_paths %CORE_ROOT%%3B%25CD% /out DynamicMethodGCStress.ni.exe DynamicMethodGCStress.exe +set ExePath=DynamicMethodGCStress.ni.exe +set COMPlus_GCStress=3 +]]></CLRTestBatchPreCommands> + <BashCLRTestPreCommands><![CDATA[ +$(BashCLRTestPreCommands) +$CORE_ROOT/crossgen -readytorun -platform_assemblies_paths $CORE_ROOT:`pwd` -out DynamicMethodGCStress.ni.exe DynamicMethodGCStress.exe +ExePath=DynamicMethodGCStress.ni.exe +export COMPlus_GCStress=3 +]]></BashCLRTestPreCommands> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> |