forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing explicit frame pop on arm32 (dotnet#101147)
* Fix missing explicit frame pop on arm32 There is an edge case during exception handling on arm32 where an active InlinedCallFrame is not popped from the explicit frame list. That later leads to various kinds of failures / crashes. For example, the on Alpine arm32, the `dotnet help` hangs eating 100% of one CPU core. That happens due to code executing after the exception was handled and its stack overwriting the explicit frame contents. This can only occur when the pinvoke is inlined in a method that calls it inside of a try region with catch in the same method and exception occurs e.g. due to the target native function or the shared library not existing. What happens is that when we pop the explicit frame, we pop frames that are below the SP of the resume location after catch. But the InlinedCallFrame is in this case above that SP, as it was created in the prolog of the method. To fix that, we need to pop that frame too. The fix uses the same condition as the old EH was using. Closes dotnet#100536 * Remove forcing crossgen and filtering by target arch for the test * Reflect PR feedback --------- Co-authored-by: Jan Vorlicek <jan.vorlicek@volny,cz>
- Loading branch information
1 parent
51615cd
commit 2abead6
Showing
3 changed files
with
92 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using Xunit; | ||
|
||
public class Test100536 | ||
{ | ||
[DllImport("__test", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Nonexistent")] | ||
private static extern IntPtr Nonexistent(); | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] | ||
private static void GarbleStack() | ||
{ | ||
Span<byte> local = stackalloc byte[4096]; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static void Test() | ||
{ | ||
try | ||
{ | ||
Nonexistent(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine($"Expected exception {ex} caught"); | ||
} | ||
} | ||
|
||
[Fact] | ||
public static void TestEntryPoint() | ||
{ | ||
Test(); | ||
GarbleStack(); | ||
GC.Collect(); | ||
} | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
src/tests/Regressions/coreclr/GitHub_100536/test100536.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> | ||
<CLRTestPriority>1</CLRTestPriority> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="test100536.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> | ||
</ItemGroup> | ||
</Project> |