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

Debugger should not manage exceptions during shutdown #105270

Conversation

mikelle-rogers
Copy link
Member

When we are in the process of shutting down the EE, we do not want the debugger to manage any exceptions. The EE should continue to shut down and the debugger should ignore the exception.

Fixes #90079

@mikelle-rogers mikelle-rogers marked this pull request as ready for review July 22, 2024 18:56
@@ -5466,6 +5466,12 @@ bool Debugger::FirstChanceNativeException(EXCEPTION_RECORD *exception,
CONTRACTL_END;


if ((g_fEEShutDown & ShutDown_Finalize2) == ShutDown_Finalize2)
Copy link
Member

Choose a reason for hiding this comment

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

How does this behave if the case that triggered this is an int3/bp that we set? Will we race to crash with the runtime that's shutting down?

Copy link
Member

@noahfalk noahfalk Jul 22, 2024

Choose a reason for hiding this comment

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

Agreed with @hoyosjs - in cases where the debugger set a breakpoint by overwriting a pre-existing instruction ignoring the OS notification probably results in a crash, hang, or executing unintended assembly instructions. Two potential solutions:

  1. Skip over the breakpoint as normal but potentially forego delivering the cross-process debugger notification.
  2. Remove all breakpoint patches at an earlier point in shutdown so that no exception is generated in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

Skip over the breakpoint as normal but potentially forego delivering the cross-process debugger notification.

I think this is the best way to fix the issue.

Remove all breakpoint patches at an earlier point in shutdown so that no exception is generated in the first place

We would need to ensure that no threads are executing the patches before proceeding. To do that, we would need to suspend the runtime that can come with a new set of issues. In general, we try to minimize amount of code that runs during shutdown. We just try to do the absolute minimum required to allow shutdown to progress. The first option fits the bill better.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the first option, having two was mostly to afford some flexibility in case one ran into unforeseen issues. Agreed that the 2nd option requires more deliberate work in the shutdown code path.

Copy link
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2024
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.

Avalonia calling into the runtime after shut down
4 participants