-
Notifications
You must be signed in to change notification settings - Fork 5k
[release/7.0] Fix edit and continue in VS with hardware exceptions #76427
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
Conversation
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.
It may be a good idea to ask Visual Studio to run their test suite on this fix. |
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. |
There was a problem hiding this 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.
Approved, signed off, CI green. |
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.