Cleanup crashes fix#526
Closed
bssth wants to merge 3 commits into
Closed
Conversation
Owner
|
I kinda wanna try a different approach, it's roughly like the approach they take in the open.mp server repo:
SafeEventHandlerRegistration should hold one of these safe component handles; it can simply check HasValue of the reference before calling RemoveEventHandler at that point. |
Owner
|
The proper fix was actually really simple, but I only found out after i implemented a safe component handle mechanism... context.UnhandledExceptionHandler = UnhandledExceptionHandler;
+ context.Cleanup += ContextOnCleanup;
+
LoadSystems();
// Fire initial event
OnGameModeInit();
}
- protected override void Cleanup()
+ private void ContextOnCleanup(object? sender, EventArgs e)
{
OnGameModeExit();
if (_serviceProvider is IDisposable disposable)
{
- // TODO: This cleanup is called so late - we can't unsubscribe event handlers anymore, but the disposables in registered systems will try to unsubscribe them. This may cause a System.ExecutionEngineException on shutdown.
disposable.Dispose();
_serviceProvider = null;
}
}I'll implement the safe handle mechanism anyway since it is good practice. |
Contributor
Author
|
My version was originally designed to be dumb but functional, because it’s no good if it crashes on shutdown. Seems like this PR is no longer relevant and we can close it. |
Owner
|
Indeed, fixed in #552 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I don't know if this "fix" works for you, but I can't think of any other way to do it. Without this fix, my server shuts down in very ugly way with crash