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

Uninitializing engine singletons makes the engine try to call free callbacks to GDExtensions that are already uninitialized #101465

Open
adamscott opened this issue Jan 12, 2025 · 2 comments · May be fixed by #101466

Comments

@adamscott
Copy link
Member

adamscott commented Jan 12, 2025

Tested versions

Reproducible in: Godot v4.4.dev (5b52b4b)

System information

Godot v4.4.dev (5b52b4b) - macOS Sequoia (15.2.0) - Multi-window, 1 monitor - OpenGL 3 (Compatibility) - Apple M3 Max - Apple M3 Max (16 threads)

Issue description

The editor (and the games, surely) crash when exiting when having some GDExtensions that have callbacks.

The issue stems from this code in Object::~Object() (core/object/object.cpp) when it tries to run callbacks to GDExtensions when they have already been uninitialized.

godot/core/object/object.cpp

Lines 2207 to 2214 in 5b52b4b

if (_instance_bindings != nullptr) {
for (uint32_t i = 0; i < _instance_binding_count; i++) {
if (_instance_bindings[i].free_callback) {
_instance_bindings[i].free_callback(_instance_bindings[i].token, this, _instance_bindings[i].binding);
}
}
memfree(_instance_bindings);
}

I experienced it about the Time singleton being deleted. That memdelete comes from #87635.

Steps to reproduce

  1. Create a new project
  2. Install DebugDraw3D (https://godotengine.org/asset-library/asset/1766)
  3. Quit the project.

Minimal reproduction project (MRP)

gh#101465.zip

@dsnopek
Copy link
Contributor

dsnopek commented Jan 13, 2025

Thanks!

This issue seems to be the same as godotengine/godot-cpp#889, for which we made PR godotengine/godot-cpp#1458 for godot-cpp.

Do you know if DebugDraw3D is using a version of godot-cpp that includes that fix? If not, then I think it'll be fixed when they update.

In any case, this is a really tricky problem, that took a lot of discussion to find an acceptable fix for. I really hope that it isn't back, and that it's just a matter of that GDExtension being on an old version of godot-cpp. :-)

@akien-mga akien-mga changed the title Unitiliazling engine singletons makes the engine try to call free callbacks to GDExtensions that are already uninitialized Uninitializing engine singletons makes the engine try to call free callbacks to GDExtensions that are already uninitialized Jan 14, 2025
@DmitriySalnikov
Copy link
Contributor

Do you know if DebugDraw3D is using a version of godot-cpp that includes that fix?

The asset-library version still uses godot-cpp 4.1-cherrypicks-12 (latest 13).
And this version seems to crash not only in 4.4, but also in 4.3.

The latest (not yet released) version of the library with godot-cpp 4.1-cherrypicks-13 does not crash for me.

@Repiteo Repiteo modified the milestones: 4.4, 4.x Feb 25, 2025
@AThousandShips AThousandShips removed this from the 4.x milestone Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants