-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Release Engine after unregistering GDExtensions #92060
Release Engine after unregistering GDExtensions #92060
Conversation
The Engine is used to retrieve singletons, and GDExtensions may try to retrieve a singleton (e.g.: `OS`) in their deinitialization.
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.
This makes sense to me.
Engine
is created before initialize_modules(MODULE_INITIALIZATION_LEVEL_CORE)
, so it would make sense that it's deleted after uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE)
, since we want to clean things up in basically the reverse order that we created them.
Thanks! |
I noticed we didn't handle the other two cleanup sections in But this change also creates an issue with the StringNames allocated by Engine, which are now not properly freed before calling |
We could move the All that matters to me is that the diff --git a/main/main.cpp b/main/main.cpp
index af29e18c46..e4ecbe64c7 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -830,13 +830,15 @@ void Main::test_cleanup() {
if (globals) {
memdelete(globals);
}
- if (engine) {
- memdelete(engine);
- }
unregister_core_driver_types();
unregister_core_extensions();
uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE);
+
+ if (engine) {
+ memdelete(engine);
+ }
+
unregister_core_types();
OS::get_singleton()->finalize_core();
@@ -2482,15 +2484,17 @@ error:
if (globals) {
memdelete(globals);
}
- if (engine) {
- memdelete(engine);
- }
if (packed_data) {
memdelete(packed_data);
}
unregister_core_driver_types();
unregister_core_extensions();
+
+ if (engine) {
+ memdelete(engine);
+ }
+
unregister_core_types();
OS::get_singleton()->_cmdline.clear();
@@ -4339,12 +4343,13 @@ void Main::cleanup(bool p_force) {
unregister_core_driver_types();
unregister_core_extensions();
uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE);
- unregister_core_types();
if (engine) {
memdelete(engine);
}
+ unregister_core_types();
+
OS::get_singleton()->benchmark_end_measure("Shutdown", "Total");
OS::get_singleton()->benchmark_dump();
I'll make a PR. |
The Engine is used to retrieve singletons, and GDExtensions may try to retrieve a singleton (e.g.:
OS
) in their deinitialization.MRP: GDExtensionSingletonCrash.zip
The MRP shows the following errors and then crashes: