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

Remove preventing EH and entering EE at shutdown #100293

Merged
merged 4 commits into from
Mar 27, 2024

Conversation

janvorli
Copy link
Member

Historically, the runtime was trying to block handling exceptions, entering EE and other stuff during shutdown of the runtime. We have already removed most of that in the past, since it has been a deadlock farm. While debugging a customer issue, I have found that we are still preventing some things to happen during shutdown. We stop handling exceptions at all and we also prevent entering EE at few places. This change removes these, as the plan we've been on is to keep the runtime running until the OS itself stops the process. In the customer's case, the problem was that during a machine shutdown, .NET runtime was generating watson dump due to an unhandled exception stemming from a network socket related code that would otherwise be handled.

Historically, the runtime was trying to block handling exceptions,
entering EE and other stuff during shutdown of the runtime. We have
already removed most of that in the past, since it has been a deadlock
farm. While debugging a customer issue, I have found that we are still
preventing some things to happen during shutdown. We stop handling
exceptions at all and we also prevent entering EE at few places.
This change removes these, as the plan we've been on is to keep the
runtime running until the OS itself stops the process.
In the customer's case, the problem was that during a machine
shutdown, .NET runtime was generating watson dump due to an unhandled
exception stemming from a network socket related code that would otherwise
be handled.
@janvorli janvorli added this to the 9.0.0 milestone Mar 26, 2024
@janvorli janvorli self-assigned this Mar 26, 2024
@janvorli
Copy link
Member Author

@jkotas I am planning to remove the CanCallRuntimeInterfaceImplementations in a secondary commit, I just wanted to get everything verified by the CI without that change first.

@janvorli janvorli requested review from jkotas and removed request for jkoritzinsky March 26, 2024 15:52
@mangod9
Copy link
Member

mangod9 commented Mar 26, 2024

Assume this will work with both current and legacy exception handling?

@janvorli
Copy link
Member Author

/azp run runtime-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

src/coreclr/vm/ceemain.cpp Outdated Show resolved Hide resolved

// No longer process exceptions
g_fNoExceptions = true;

// <TODO>@TODO: This does things which shouldn't occur in part 2. Namely,
// calling managed dll main callbacks (AppDomain::SignalProcessDetach), and
// RemoveAppDomainFromIPC.
Copy link
Member

@jkotas jkotas Mar 26, 2024

Choose a reason for hiding this comment

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

I am looking at what we do below and there seems to be more instances of questionable cleanup:

  • CLRRemoveVectoredHandlers
  • StubManager::TerminateStubManagers - it should just flush the debug-only log, but it should not be destroying the Crsts
  • Interpreter::Terminate

Copy link
Member Author

Choose a reason for hiding this comment

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

The Disassembler::StaticClose(); frees the disassembler shared library, it also sounds like something we should not do.

Copy link
Member Author

Choose a reason for hiding this comment

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

StubManager::TerminateStubManagers - it actually doesn't do anything interesting. The whole log is just a SString instance that is never accessed in any way - there is a StubManager::DbgGetLog method, but nothing calls it.

@janvorli
Copy link
Member Author

/azp run runtime-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@janvorli janvorli merged commit fd22b92 into dotnet:main Mar 27, 2024
146 checks passed
@janvorli janvorli deleted the remove-eh-and-ee-entering-prohibition branch March 27, 2024 16:08
@janvorli
Copy link
Member Author

janvorli commented Apr 8, 2024

/backport to release/8.0-staging

Copy link
Contributor

github-actions bot commented Apr 8, 2024

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/8607836627

Copy link
Contributor

github-actions bot commented Apr 8, 2024

@janvorli backporting to release/8.0-staging failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Remove preventing EH and entering EE at shutdown
Using index info to reconstruct a base tree...
M	src/coreclr/vm/ceemain.cpp
M	src/coreclr/vm/crst.h
M	src/coreclr/vm/eepolicy.cpp
M	src/coreclr/vm/excep.cpp
M	src/coreclr/vm/i386/excepx86.cpp
M	src/coreclr/vm/runtimecallablewrapper.cpp
M	src/coreclr/vm/threads.cpp
M	src/coreclr/vm/vars.cpp
M	src/coreclr/vm/vars.hpp
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/vm/vars.hpp
Auto-merging src/coreclr/vm/vars.cpp
Auto-merging src/coreclr/vm/threads.cpp
Auto-merging src/coreclr/vm/runtimecallablewrapper.cpp
Auto-merging src/coreclr/vm/i386/excepx86.cpp
Auto-merging src/coreclr/vm/excep.cpp
CONFLICT (content): Merge conflict in src/coreclr/vm/excep.cpp
Auto-merging src/coreclr/vm/eepolicy.cpp
Auto-merging src/coreclr/vm/crst.h
Auto-merging src/coreclr/vm/ceemain.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Remove preventing EH and entering EE at shutdown
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

github-actions bot commented Apr 8, 2024

@janvorli an error occurred while backporting to release/8.0-staging, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

janvorli added a commit to janvorli/runtime that referenced this pull request Apr 9, 2024
janvorli added a commit to janvorli/runtime that referenced this pull request Apr 10, 2024
ericstj pushed a commit that referenced this pull request Apr 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 9, 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.

3 participants