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 ClassDB not checking for editor classes properly #92345

Merged
merged 1 commit into from
May 28, 2024

Conversation

mihe
Copy link
Contributor

@mihe mihe commented May 24, 2024

This fixes the _instantiate_internal, can_instantiate and is_virtual methods of ClassDB to not only check whether ClassInfo::api is API_EDITOR but also whether it's API_EDITOR_EXTENSION.

This bug led to a crash when running @qarmin's fuzzer on Godot Jolt, as seen in godot-jolt/godot-jolt#868, as it tried to instantiate an editor-only type that erroneously reported a successful can_instantiate.

@dsnopek You wouldn't happen to know if this needs the same change? I couldn't quite figure out what it's for:

placeholder_extension->editor_class = ti->api == API_EDITOR;

@mihe mihe requested a review from a team as a code owner May 24, 2024 22:32
@mihe mihe changed the title Fix ClassDB not checking for API_EDITOR_EXTENSION Fix ClassDB not checking for editor classes properly May 24, 2024
@AThousandShips AThousandShips added this to the 4.3 milestone May 25, 2024
@adamscott
Copy link
Member

@mihe @dsnopek What's weird is that it's assigning a boolean as the value instead of the enum value.

placeholder_extension->editor_class = ti->api == API_EDITOR;

@dsnopek
Copy link
Contributor

dsnopek commented May 25, 2024

@dsnopek You wouldn't happen to know if this needs the same change?

No, I don't think it should need it there. That's inside a block that will only execute if the class isn't an extension class.

@dsnopek dsnopek requested a review from a team May 25, 2024 15:20
Copy link
Contributor

@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! Looks good to me :-)

@dsnopek dsnopek added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label May 25, 2024
@dsnopek
Copy link
Contributor

dsnopek commented May 25, 2024

@dsnopek What's weird is that it's assigning a boolean as the value instead of the enum value.

Yeah, that one is a boolean. This code is making a "fake" GDExtension class to represent a placeholder for a runtime class, and ObjectGDExtension::editor_class is a boolean.

@akien-mga akien-mga merged commit 760e30a into godotengine:master May 28, 2024
16 checks passed
@mihe mihe deleted the classdb-extension-editor-classes branch May 28, 2024 14:40
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release topic:core topic:gdextension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants