-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/8.0] Fix a possible infinite wait for GC completion at proce…
…ss shutdown. (#107844) * Add a test * Minimal part of "Use RtlDllShutdownInProgress to detect process shutdown on Windows (#103877)" Fixes:107800 * Use RtlDllShutdownInProgress to detect process shutdown on Windows Switching to cooperative mode is not safe during process shutdown on Windows. Process shutdown can terminate a thread in the middle of the GC. The shutdown thread deadlocks if it tries to switch to cooperative mode and wait for the GC to finish in this situation. Use RtlDllShutdownInProgress Windows API to detect process shutdown to avoid waiting for GC completion when that may lead to deadlocks. * Update src/coreclr/vm/vars.hpp Co-authored-by: Manish Godse <61718172+mangod9@users.noreply.github.com> --------- Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Manish Godse <61718172+mangod9@users.noreply.github.com>
- Loading branch information
1 parent
f34e9ac
commit 1f0e1bd
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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.Threading; | ||
using System.Threading.Tasks; | ||
|
||
public class Program | ||
{ | ||
public static int Main() | ||
{ | ||
Task.Run(() => | ||
{ | ||
for (; ; ) | ||
{ | ||
GC.Collect(); | ||
} | ||
}); | ||
|
||
Thread.Sleep(10); | ||
Environment.Exit(100); | ||
|
||
throw new Exception("UNREACHABLE"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/tests/Regressions/coreclr/GitHub_107800/test107800.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<!-- Calls ExitProcess --> | ||
<RequiresProcessIsolation>true</RequiresProcessIsolation> | ||
<CLRTestPriority>0</CLRTestPriority> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="test107800.cs" /> | ||
</ItemGroup> | ||
</Project> |