[release/6.0] Fix exception propagation over HW exception frame on macOS 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>