-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
GDExtension method calls should not pass nullptr args #87613
GDExtension method calls should not pass nullptr args #87613
Conversation
Hm. I'll do some more "historical" investigation when I have a chance, but if we've really been encoding null objects this way in 4.0, 4.1, and 4.2, I'd be reluctant to change this in Godot, because if it's been consistent, this sounds more like a godot-cpp bug. |
df879af
to
8fb744a
Compare
pretty sure a bug in godot itsself,, i mean it doesnt even reach the gdextension dll,, |
8fb744a
to
a05894b
Compare
hmmm, the failed check is a cancelled ios build,,, |
Sorry for taking so long to get back to this! I didn't do any testing, but I skimmed the code from 4.0, 4.1 and 4.2, and it does appear that we've been encoding null So, I'm personally against making this change in Godot. I think consistency with previous versions is important unless there is a clear advantage to changing the encoding, and I don't think there is in this case (in fact, I think the current encoding is slightly better because we don't have to dereference the I think the crash should be fixed in godot-cpp instead |
i dont think this comment makes sense, this is a crash that happens when a validated call is made and a
it actually seems like D bindings Dont make this check, since its a validated call, i doubt a null check should be done ,, it would need to get added in a couple places, it seems unlikely that someone just forgot that, i was interpreting the |
@vnen i see your name and reduz in the commit log for gdextension validated ptrcall ,, do you have insight about this? |
Here's alternative PR godotengine/godot-cpp#1405 which fixes the issue in godot-cpp rather than Godot itself. I've also added discussion of this issue to the agenda of the next GDExtension meeting. (If anyone is interested in participating, please stop by #gdextension on chat.godotengine.org for details about the GDExtension meetings.) |
We discussed this at the GDExtension meeting, and felt that it would be great if @Bromeon (or other maintainers of GDExtension bindings) could weigh in on the current encoding of |
In godot rust, null objects in argument calls are passed as pointers to null object pointers in all version of godot except 4.0. In 4.0 we pass them directly as null pointers. However we also dont use null objects directly all that frequently (im unsure if we ever do actually) when calling gdextension methods since we have an outstanding bug where direct method calls only allow for non-null objects. The current workaround there is to use I dont think it would really impact much if we end up needing to switch to encoding them as null pointers instead. |
(Adding this comment just to differentiate my personal opinion from what I wrote in my previous comment, which was the result of that GDExtension meeting, and isn't the same as my personal view.) As I've stated previously, it's my opinion that we don't really gain anything by changing the encoding as proposed in this PR: both the current encoding and the proposed encoding are capable of representing a null The only advantage to changing the encoding is theoretical "correctness", if the proposed encoding more closely matches the original intention for the encoding (however, it's not totally clear what the original intention was). My personal vote is still for keeping the current encoding. Regardless of the intention, it's the encoding we've been using in all versions of Godot 4.x, and it's capable of representing what we need it to, so I see no compelling reason to change it. But we certainly could improve the overall situation by documenting the encoding, so that it's clearer to the implementors of GDExtension bindings. |
That is reasonable, assuming that this is not a limitation but rather choice of representation, and every binding is capable to represent null pointers. It would also prevent bindings from possibly needing to deal with different behavior across multiple API versions. As such, I'm with you here 🙂 |
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.
Seems good, great catch.
Sorry I though this was a fix, so adding to the discussion: Regarding the intention of the encoding, I think (if I am not mistaken) it was that it passed a pointer to a pointer for returning, and a single pointer for argument passing. The problem is that this caused a lot of issues so I think at some point it was changed? I honestly would use what work best for you, since you are the consumers of the API at this point. |
I checked #1405 and this looks like a better solution I guess, since each platform can handle it as preferred? |
Superseded by PR godotengine/godot-cpp#1405 |
fix for a nasty crash that happens when passing a null variant to any gdextension function parameter expecting any kind of Object *.
the GDExtensionMethodBind expects a pointer to an
Object *
butget_opaque_pointer
returns a nullptr which it tries to dereference..could also be fixed in godot-cpp with a nullptr check, but this seemed more in line with what the binding code expects
this or another fix should rlly be applied to 4.2, 4.1, nd 4.0
it can be easily cherrypicked for 4.2 but 4.1 and 4.0 have different binding code, ill make a PR for 4.1 when its apropriate
fixes #86478
fixes godotengine/godot-cpp#1056