Skip to content

[release/6.0] Fix exception propagation over HW exception frame on macOS arm64 #63524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jan 8, 2022

Backport of #63482 to release/6.0

/cc @janvorli

There is a bug in hardware exception handling on macOS arm64 in setting up
the fake stack frame for the PAL_DispatchExceptionWrapper. Unwinding
while propagating an exception through the frame that caused the hardware
exception restores incorrect value of the LR register.

Customer Impact

Attempt to throw a new exception or rethrow from a catch handler of a NullReferenceException that stemmed from a virtual call on a null reference results in a SIGSEGV crash of the process on macOS arm64.

Testing

coreclr and libraries tests, targeted regression test.

Risk

Low. With the change, the unwind gets an exact copy of the frame of the hardware exception that was reported by the OS. So it is correct by definition.

There is a bug in setting up the fake stack frame for
the PAL_DispatchExceptionWrapper. The FP and SP were not saved
to the stack frame and the FP of the context was not set to
match the fake prologue. That caused failure to unwind over the
PAL_DispatchExceptionWrapper, reaching an unrelated native
function.

This change fixes it.
Unifies the hardware exception frame unwinding with Linux,
it is necessary on arm64 to get correct and distinct LR and
PC in the frame of the hardware exception.
@ghost ghost added the area-PAL-coreclr label Jan 8, 2022
@janvorli janvorli self-assigned this Jan 8, 2022
@janvorli janvorli requested a review from jkotas January 8, 2022 01:55
@janvorli janvorli added this to the 6.0.x milestone Jan 8, 2022
@janvorli janvorli added Servicing-consider Issue for next servicing release review arch-arm64 os-mac-os-x macOS aka OSX labels Jan 8, 2022
@danmoseley
Copy link
Member

System.Composition.Hosting.Core.Tests.ExportDescriptorPromiseTests.GetDescriptor_GetWhenNull_ThrowsNullReferenceException timed out. Coincidental, most likely as altough it's macOS it's x64.

@janvorli
Copy link
Member

janvorli commented Jan 8, 2022

@danmoseley thank you for pointing it out. I'll test it locally.

@janvorli
Copy link
Member

janvorli commented Jan 8, 2022

There is really something wrong with the EH in this test. The EH gets into an infinite loop, so there is something subtle that I must have missed.

@janvorli
Copy link
Member

janvorli commented Jan 8, 2022

I am closing this porting PR until the issue is found and fixed.

@janvorli janvorli closed this Jan 8, 2022
@k15tfu
Copy link
Contributor

k15tfu commented Jan 9, 2022

I see that there is no such Libraries Test Run build for OSX arm64, probably that's why only x64 build failed.

@danmoseley
Copy link
Member

/azp list

@danmoseley
Copy link
Member

/azp help

@danmoseley
Copy link
Member

It should be possible to request it next time with /azp run runtime-libraries-coreclr outerloop-osx. That seems to include both x64 and arm64.

@janvorli
Copy link
Member

janvorli commented Jan 9, 2022

The failure is intermittent, that's why I haven't hit it in the main branch and local testing. But I am able to repro it locally in a reasonable number of attempts.

@jkotas jkotas deleted the backport/pr-63482-to-release/6.0 branch January 22, 2022 08:02
@ghost ghost locked as resolved and limited conversation to collaborators Feb 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm64 area-PAL-coreclr os-mac-os-x macOS aka OSX Servicing-consider Issue for next servicing release review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants