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

Exceptions thrown in a class finalizer will cause the game to crash #1147

Open
peter-r-g opened this issue Oct 23, 2021 · 3 comments
Open

Exceptions thrown in a class finalizer will cause the game to crash #1147

peter-r-g opened this issue Oct 23, 2021 · 3 comments
Assignees

Comments

@peter-r-g
Copy link

peter-r-g commented Oct 23, 2021

Describe the bug
Getting any kind of exception within a class's finalizer will cause your game to crash. In your console, you'll see an "AppDomain unhandled exception" then the game will close.

To Reproduce

  1. Create a class with a finalizer
  2. Have an exception thrown inside of said finalizer.
  3. Game closes with no crash message when the class is GCed.

Expected behavior
For an exception to be logged to the console and for the game to not crash.

Additional context
Created a shell of a game so you can reproduce it easily.
Game is bughunt.finalizerbug
Crash code is here

@peter-r-g peter-r-g added the bug label Oct 23, 2021
@garrynewman garrynewman self-assigned this Oct 23, 2021
@Rohansi
Copy link

Rohansi commented Oct 23, 2021

This probably isn't possible to fix at this time -> dotnet/runtime#42275

This specific scenario could be fixed by injecting a try catch around all finalizers.

@darkguy2008
Copy link

darkguy2008 commented Mar 8, 2022

This probably isn't possible to fix at this time -> dotnet/runtime#42275

This specific scenario could be fixed by injecting a try catch around all finalizers.

It seems the issue is gaining some traction now (yay!) and there is an active ongoing discussion, everyone is welcome to chime in, it seems :)

@peter-r-g
Copy link
Author

The dotnet team created a new issue dotnet/runtime#101560 and approved the API. Looks like the plan is for it to be brought in at .NET 9

@handsomematt handsomematt removed the bug label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants