diff options
author | Koundinya Veluri <kouvel@users.noreply.github.com> | 2021-06-02 17:28:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-02 17:28:59 +0300 |
commit | f495f7ecfa8186e226bf21abcdfdb5682b25136b (patch) | |
tree | e8b49b76c5b4607a82e5116695f2a29d8f3c1c4f /src/tests/baseservices | |
parent | 1b8e971c1a4da7bd122510a6bfd59f8702cab344 (diff) |
Fix assertion failure / crash in multi-core JIT (#53573)
* Fix assertion failure / crash in multi-core JIT
- When the recorder times out it doesn't actually stop profiling, but writes out the profile
- The app may later stop profiling, and then it tries to write the profile again
- PR https://github.com/dotnet/runtime/pull/48326 fairly expected that the profile is only written once (some state is mutated)
- The non-timeout stop-profile path was also not stopping the timer
- Fix for https://github.com/dotnet/runtime/issues/53014 in main
Diffstat (limited to 'src/tests/baseservices')
-rw-r--r-- | src/tests/baseservices/TieredCompilation/McjRecorderTimeoutBeforeStop.cs | 33 | ||||
-rw-r--r-- | src/tests/baseservices/TieredCompilation/McjRecorderTimeoutBeforeStop.csproj | 21 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/tests/baseservices/TieredCompilation/McjRecorderTimeoutBeforeStop.cs b/src/tests/baseservices/TieredCompilation/McjRecorderTimeoutBeforeStop.cs new file mode 100644 index 00000000000..14ecd4785f1 --- /dev/null +++ b/src/tests/baseservices/TieredCompilation/McjRecorderTimeoutBeforeStop.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime; +using System.Runtime.CompilerServices; +using System.Threading; + +public static class BasicTest +{ + private static int Main() + { + const int Pass = 100; + + ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory); + ProfileOptimization.StartProfile("profile.mcj"); + + // Record a method + Foo(); + + // Let the multi-core JIT recorder time out. The timeout is set to 1 s in the test project. + Thread.Sleep(2000); + + // Stop the profile again after timeout (just verifying that it works) + ProfileOptimization.StartProfile(null); + return Pass; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static void Foo() + { + } +} diff --git a/src/tests/baseservices/TieredCompilation/McjRecorderTimeoutBeforeStop.csproj b/src/tests/baseservices/TieredCompilation/McjRecorderTimeoutBeforeStop.csproj new file mode 100644 index 00000000000..05feffa608c --- /dev/null +++ b/src/tests/baseservices/TieredCompilation/McjRecorderTimeoutBeforeStop.csproj @@ -0,0 +1,21 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <OutputType>Exe</OutputType> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <ItemGroup> + <Compile Include="McjRecorderTimeoutBeforeStop.cs" /> + </ItemGroup> + <PropertyGroup> + <CLRTestBatchPreCommands><![CDATA[ +$(CLRTestBatchPreCommands) +set COMPlus_MultiCoreJitProfileWriteDelay=1 +]]></CLRTestBatchPreCommands> + <BashCLRTestPreCommands><![CDATA[ +$(BashCLRTestPreCommands) +export COMPlus_MultiCoreJitProfileWriteDelay=1 +]]></BashCLRTestPreCommands> + </PropertyGroup> +</Project> |