-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/6.0] Fix exception propagation over HW exception frame on ma…
…cOS arm64 (#64262) * Fix exception propagation over HW exception frame on macOS arm64 There is a problem unwinding over the PAL_DispatchExceptionWrapper to the actual hardware exception location. The unwinder is unable to get distinct LR and PC in that frame and sets both of them to the same value. This is caused by the fact that the PAL_DispatchExceptionWrapper is just an injected fake frame and there was no real call. Calls always return with LR and PC set to the same value. The fix unifies the hardware exception frame unwinding with Linux where we had problems unwinding over signal handler trampoline, so PAL_VirtualUnwind skips the trampoline and now also the PAL_DispatchExceptionWrapper frame by copying the context of the exception as the unwound context. * Fix GC stress C - wrong context being restored The context that is restored in the PAL_DispatchException needs to be the one from the exception, not the original saved one. That ensures that the registers updated by the GC in GC stress C in the context are properly restored after the execution is resumed. * Fix exception context leak in GC stress C The PAL_SEHException had the records allocated on stack, so the direct context restoration after the EH for GC stress C completed leaked those. Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
- Loading branch information
1 parent
3b0b34c
commit 2caf6fb
Showing
6 changed files
with
90 additions
and
25 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
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,60 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
public class Program | ||
{ | ||
private interface IFoo | ||
{ | ||
bool IsValid { get; } | ||
} | ||
|
||
private class Foo : IFoo | ||
{ | ||
public bool IsValid { get; set; } | ||
} | ||
|
||
public static int Main(string[] args) | ||
{ | ||
bool warmup = new Foo().IsValid; | ||
CatchIgnore(() => | ||
CatchRethrow(() => | ||
{ | ||
IFoo[] foos = {new Foo(), null}; | ||
foreach (var foo in foos) | ||
{ | ||
bool check = foo.IsValid; | ||
} | ||
})); | ||
|
||
return 100; | ||
} | ||
|
||
public static void CatchRethrow(Action action) | ||
{ | ||
try | ||
{ | ||
action.Invoke(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.Out.WriteLine("catch"); | ||
Console.Out.Flush(); | ||
throw new Exception("catch", e); | ||
} | ||
} | ||
|
||
public static void CatchIgnore(Action action) | ||
{ | ||
try | ||
{ | ||
action.Invoke(); | ||
} | ||
catch (Exception) | ||
{ | ||
Console.Out.WriteLine("ignore"); | ||
Console.Out.Flush(); | ||
} | ||
} | ||
} |
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,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<CLRTestPriority>1</CLRTestPriority> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="test62058.cs" /> | ||
</ItemGroup> | ||
</Project> |