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

add_virtual_method with parameter crashes engine when loading editor #1580

Open
hakuhan opened this issue Sep 12, 2024 · 1 comment · May be fixed by #1581
Open

add_virtual_method with parameter crashes engine when loading editor #1580

hakuhan opened this issue Sep 12, 2024 · 1 comment · May be fixed by #1581

Comments

@hakuhan
Copy link

hakuhan commented Sep 12, 2024

Godot version

4.3

godot-cpp version

4.3

System information

Windows 11

Issue description

When I regist a method with a parameter to be virtual for godot. Editor crashed when launching.
I think it is caused by empty arguments_metadata in created MethodInfo.
I tried to add vector size checking code in class_db.cpp. And crash dosen't appear.
image

Steps to reproduce

  1. Regist a virtual method by calling:
    ClassDB::add_virtual_method("TestClass", MethodInfo(Variant::Type::BOOL, "func_with_parameter", PropertyInfo(Variant::STRING_NAME, "param_name", PROPERTY_HINT_NONE, "StringName", PROPERTY_USAGE_NONE)), {"param_name"});
  2. Build GDExtension.
  3. Launch game with VSCode or other IDEs.

Minimal reproduction project

Please try with steps thanks!

@hakuhan hakuhan changed the title add_virtual_method with method args crashes when loading editor add_virtual_method with parameter crashes engine when loading editor Sep 12, 2024
@dsnopek
Copy link
Collaborator

dsnopek commented Sep 12, 2024

Thanks!

It'd probably be good to add a check like you show above, but you shouldn't be directly calling ClassDB::add_virtual_method() anyway.

Instead, use the GDVIRTUAL*() and GDVIRTUAL_BIND() macros. They'll take care of all the necessary setup. You can see an example of them in the test code in test/src/example.h and test/src/example.cpp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants