-
-
Notifications
You must be signed in to change notification settings - Fork 589
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
Clean up instance bindings for engine singletons to prevent crash #1458
Conversation
I'm running into some issues with this it seems:
|
Thanks for testing!
Ah, I'll look into that. Multiple threads requesting the singleton at the same time when it hasn't been initialized yet does seem like a problem.
Hm. Freeing the instance binding should have removed it from the list of instance bindings the object had on the Godot side, so this shouldn't be a problem. When I have a chance, I'll do my own testing with Godot Jolt. |
I can maybe take a closer look at what's happening tomorrow. If you want to try it yourself you'll have to use this fork of Godot Jolt, which uses this fork of godot-cpp. |
It does seem to be the case that the instance binding (i.e. Whichever way you turn it I feel like you'll need to override the free callback for singletons. Either you give it a |
ce63735
to
8edf073
Compare
Thanks! However, I'm having trouble reproducing the crash with Godot Jolt on my system. :-/ I wish that I could, because then I could test if my latest changes fix it.
I've attempted to take this approach in my latest push. Can you give it a try with Godot Jolt? Note: I'm not making a custom free callback, I've added the bit that removes the instance from |
Make sure you got the right branch as well, not just the fork. If you did already, maybe try with Valgrind, assuming you're on Linux. I was able to make it crash earlier when I used Application Verifier on Windows.
I can verify that it fixes that particular crash, but now instead I'm seeing another crash, which seems to be unrelated to this PR. It seems that this line is causing some trouble, because I don't quite understand why this works in Godot 4.2 though, assuming it actually does?
Oh right, I keep convincing myself that you can't implement the destructor for Godot objects for some reason. |
It does not, apparently! I guess I haven't run with Application Verifier for a good long while. The likelihood of that resulting in a crash must be very small, because I've never seen that manifest as a crash (i.e. without something like Application Verifier or Valgrind) in any of the hundreds of shutdowns I've done with Godot 4.2. That should really be fixed. |
@mihe I just made draft PR godotengine/godot#91806 which aims to fix the new crash you discovered. Could you please test that with Godot Jolt too? Hopefully, there won't be any more crashes this uncovers :-) |
I'm on it. As a sidenote, I noticed that this PR is tagged as |
8edf073
to
88df025
Compare
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.
LGTM
@mihe Thanks for all your help testing! |
Hey, thanks for the fix! Can confirm that it solves the issue on my end as well. |
Cherry-picked for 4.2 in PR #1465 |
Fixes #889
This specifically cleans up engine singletons, it doesn't address the general case where a GDExtension is unloaded before an
Object
can clean up its instance binding to that GDExtension.It includes a test that crashes at exit without this fix, but exits normally with this fix.