-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Crash during engine shutdown if get_tree()
is ever called from GDNative
#48295
Comments
Can confirm this occurs on macOS Big Sur too, where it's worse because the user will be greeted with a crash report window every time they exit. |
Related to #46844, #47655, and #47623. CC @godotengine/gdnative @geekrelief @toasteater @Bromeon |
I can confirm this happens with godot-cpp (Win10 + MSVC, using the cpp gdnative-demos codebase) but doesn't happen with godot-nim or with the C godot-headers. I only have basic familiarity with godot-cpp, but I'll try to help debug this. |
Note that godot-cpp hasn't been updated yet to match the This might get solved once this update is done. |
Thanks! Hopefully, you spared me the trouble of debugging this. I was in the middle of trying to bisect the godotengine to commits to see which commit was the cause. |
Is there any effort towards figuring out how to synchronize this stuff better? It sounds like there is always going to be a window of several weeks after every Godot release where c++ projects are not going to work. Frustrating for existing developers who do not realise that they need to wait for godot-cpp to catch up, and confusing for new c++ developers who are simply following the instructions in the godot-cpp readme. |
I can't reproduce the crash on Linux, though if I use a
But with that PR merged and the new Could you confirm that updating the headers fixes the issue for you? |
No, on Windows the same crash is occurring with the new 3.3 branch. |
On Windows 8.1 it's not crashing for me right now. The problem I got is that godot editor is locking gdnative dll for writing. I have to restart godot editor every time I change dll. |
The issue I reported isn't that Stack trace of the crash:
|
This might be stupid question sorry but are you building project by scons file or in VS? |
The reproduction project I attached in the OP uses cmake to generate a VS project. |
My project was crashing at exit (in export and editor) after some time after updating to 3.3 (editor and headers) and somehow stopped crashing after I was messing with cpp files I think forcing VS to properly rebuild. VS is very buggy. I checked your plugin.cpp file and I think it misses constructor and destructor: EDIT: what is funny project dll compiled with 3.2 headers is also not crashing in Godot 3.3 in Windows |
The constructor and destructor is irrelevant. The issue is that the plugin's |
I tried again and I finally managed to reproduce the crash on Linux. It doesn't seem to happen when running the project through the editor, but it does when running standalone. Here's a fixed MRP so that it builds properly against How to use:
Crash backtrace (from 3.3.4 RC e4df8a6, but that's close enough to 3.3.3 stable):
|
get_tree()
is ever called from GDNative
See also #48086 which seems to be related. I'd need help from motivated GDNative users to debug and fix this. Alternatively, I can revert the multiple GDNative PRs which led to this regression, but it would reintroduce other issues. |
If you need me to test something let me know. I use GDNative extensively on Windows, Linux and macOS and I can reproduce this crash consistently on all three platforms. |
It appears this workaround can be added to user code to suppress the crash extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options * o)
{
Godot::nativescript_terminate(godot::_RegisterState::nativescript_handle); // Add this line
Godot::gdnative_terminate(o);
} |
I can confirm that this issue is still present even in 3.5 beta 3. And I also confirm that your workaround works for me to suppress the crash. |
Echoing this for 3.4.4, will occur even if |
The issue still exists in Godot 3.5 paired with the Not sure if this would help at all in tracking down this bug, but intentionally leaking any node that has a NativeScript attached to it also prevents the crash on exit. Furthermore, the stack trace at the time of the crash varies based on other factors. In my case, it's narrowing down the issue to |
Is godotengine/godot-cpp#860 possibly related to this? #48295 (comment) also fixes it for me. In my case, segfault happened when both conditions were satisfied:
Strangely, doing |
Godot version:
3.3 stable
OS/device including version:
Windows 10
Issue description:
If
get_tree()
is ever called from a GDNative plugin then Godot will crash on shutdown when you quit your game.The crash occurs in
NativeScriptLanguage::free_instance_binding_data
.free_instance_binding_data
is entered butgodot_gdnative_terminate
has already been called at this point so the function pointer is invalid.This doesn't happen in Godot 3.2.
Steps to reproduce:
Call
get_tree()
from a GDNative class, run your game with a debugger attached and quit.Minimal reproduction project:
gdnative_get_tree_crash.zip
This is the only relevant part AFAIK:
The text was updated successfully, but these errors were encountered: