Skip to content
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

Fix handling of hardware exceptions in native code on Unix #69685

Merged

Conversation

janvorli
Copy link
Member

This change fixes handling of hardware exceptions like sigsegv or
division by zero that happen in native code out of our runtime helpers
and that is enclosed in the PAL_TRY / PAL_EXCEPT or PAL_FINALLY.
The current implementation was working only for the DAC code. There is a
new need to use it in SuperPMI to ensure that a log is written even in case
an access violation occured in JIT.
It still requires the shared library that wants to use it to be compiled
with FEATURE_ENABLE_HARDWARE_EXCEPTIONS, so nothing has changed for
coreclr or JIT. It also requires the PAL of that shared library to be
initialized with PAL_INITIALIZE_REGISTER_SIGNALS on Linux. On macOS,
this is not needed.

This change fixes handling of hardware exceptions like sigsegv or
division by zero that happen in native code out of our runtime helpers
and that is enclosed in the PAL_TRY / PAL_EXCEPT or PAL_FINALLY.
The current implementation was working only for the DAC code. There is a
new need to use it in SuperPMI to ensure that a log is written even in case
an access violation occured in JIT.
It still requires the shared library that wants to use it to be compiled
with FEATURE_ENABLE_HARDWARE_EXCEPTIONS, so nothing has changed for
coreclr or JIT. It also requires the PAL of that shared library to be
initialized with PAL_INITIALIZE_REGISTER_SIGNALS on Linux. On macOS,
this is not needed.
@janvorli janvorli added this to the 7.0.0 milestone May 23, 2022
@janvorli janvorli requested review from jkotas and jakobbotsch May 23, 2022 19:30
@janvorli janvorli self-assigned this May 23, 2022
Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! I've verified that this makes the exception translation work for the SPMI scenario. For posterity, that PR is #69494.

@janvorli janvorli merged commit 326e719 into dotnet:main May 24, 2022
@janvorli janvorli deleted the fix-native-code-hardware-exception-handling branch May 24, 2022 13:48
@ghost ghost locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants