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

Fix crash on virtual method calls #1404

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

AThousandShips
Copy link
Member

Could do this on the engine side but as we seem to universally assume pointers are valid for these calls on the engine side, so this ensures it works correctly regardless

@AThousandShips AThousandShips added bug This has been identified as a bug crash topic:buildsystem Related to the buildsystem or CI setup labels Mar 5, 2024
@AThousandShips AThousandShips added this to the 4.3 milestone Mar 5, 2024
@AThousandShips AThousandShips requested a review from a team as a code owner March 5, 2024 14:37
Copy link
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Could do this on the engine side but as we seem to universally assume pointers are valid for these calls on the engine side, so this ensures it works correctly regardless

This logic makes sense to me. Looking at the existing gdextension_variant_call() function in the engine, it also takes a GDExtensionUninitializedVariantPtr r_return which must always point to valid memory (ie it can't be nullptr). And, so having gdextension_object_call_script_method() work in the same way would be consistent with that.

The downside is that we're initializing a Variant that won't ever be used, but there's other ways around that we could explore in the future (such as using uninitialized memory from the stack), and that's something we could take advantage of through out godot-cpp, since there's other places we're doing this as well - which would be best explored in a different issue/PR.

@dsnopek dsnopek merged commit f444616 into godotengine:master Mar 5, 2024
12 checks passed
@AThousandShips AThousandShips deleted the virt_fix branch March 5, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This has been identified as a bug crash topic:buildsystem Related to the buildsystem or CI setup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when trying to call virtual method without return value
2 participants