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

[release/7.0] Fix edit and continue in VS with hardware exceptions #76427

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 30, 2022

Backport of #76401 to release/7.0

/cc @janvorli

Customer Impact

Without this fix, using the "unwind to this frame" functionality in Visual Studio after a hardware exception like null reference causes the debugged process to crash.

Testing

Local testing with Visual Studio, monitoring the state of the target process using non-invasively attached WinDbg at the same time and comparing the behavior with .NET 6.

Risk

Very low, it touches only the hardware exception handling path and influences only the debugger behavior.

There is a subtle bug in hardware exception handling in the runtime
that causes the debugged process to crash when a user tries to use the
"unwind to this frame" on the frame where the exception happened.
This issue was introduced by the recent changes that modified hardware
exception handling.

The problem turned out to be in how we update the exception and context
records in the HandleManagedFaultFilter when we re-raise the exception
using RaiseException from the VEH. Updating the context is both not
necessary and wrong. All we need to update is the `ExceptionAddress` in
the `EXCEPTION_RECORD`, since the RaiseException puts the address of
itself there and we need the address of the original access violation to
be there.
The context should stay untouched as we are unwinding from the
RaiseException.

The context copying was originally made to mimick the code in the
`NakedThrowHelper` used before the exception handling change. That one
needed the context update, as it was used to fix unwinding over the
NakedThrowHelper that was a hijack helper. In the current state, nothing
like that is needed.

With this fix, the VS debugger works as expected.
@janvorli janvorli self-assigned this Sep 30, 2022
@janvorli janvorli added this to the 7.0.0 milestone Sep 30, 2022
@janvorli janvorli added os-windows arch-x64 Servicing-consider Issue for next servicing release review labels Sep 30, 2022
@jkotas
Copy link
Member

jkotas commented Sep 30, 2022

Local testing with Visual Studio, monitoring the state of the target process using non-invasively attached WinDbg at the same time and comparing the behavior with .NET 6.

It may be a good idea to ask Visual Studio to run their test suite on this fix.

@jkotas
Copy link
Member

jkotas commented Sep 30, 2022

Very low, it touches only the hardware exception handling path and influences only the debugger behavior.

Nit: I would not characterize the risk as very low. The test coverage for these areas is not great and this is not the first regression we are fixing after the recent hardware exception handling changes.

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

approved. we will take for consideration in 7 ga.

@tommcdon tommcdon self-requested a review September 30, 2022 14:43
@jeffschwMSFT jeffschwMSFT added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 30, 2022
@carlossanlop
Copy link
Member

Approved, signed off, CI green. :shipit:

@carlossanlop carlossanlop merged commit 0a09c8f into release/7.0 Sep 30, 2022
@carlossanlop carlossanlop deleted the backport/pr-76401-to-release/7.0 branch September 30, 2022 21:31
@ghost ghost locked as resolved and limited conversation to collaborators Oct 31, 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.

6 participants