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

crash when a gdextension registers a static method #61963

Closed
nathanfranke opened this issue Jun 12, 2022 · 2 comments · Fixed by godotengine/godot-cpp#778
Closed

crash when a gdextension registers a static method #61963

nathanfranke opened this issue Jun 12, 2022 · 2 comments · Fixed by godotengine/godot-cpp#778

Comments

@nathanfranke
Copy link
Contributor

Godot version

v4.0.alpha.custom_build [8df8fff]

System information

Arch on 5.15.45-1-lts

Issue description

Editing project: /home/nathan/Downloads/godot-cpp/test/demo (::home::nathan::Downloads::godot-cpp::test::demo)
Godot Engine v4.0.alpha.custom_build.8df8fff54 - https://godotengine.org
Vulkan API 1.2.0 - Using Vulkan Device #0: AMD - AMD RADV SIENNA_CICHLID
Constructor.
Destructor.

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.alpha.custom_build (8df8fff54ba2263d53448b0a7f4e33fa76fdea50)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /usr/lib/libc.so.6(+0x3e8e0) [0x7fb8ac5b98e0] (??:0)
[2] StringName::StringName(char const*, bool) (??:0)
[3] NativeExtensionMethodBind::_gen_argument_type_info(int) const (??:0)
[4] MethodBind::get_return_info() const (??:0)
[5] /home/nathan/workspace/public/godot/bin/godot.linuxbsd.tools.64.llvm(+0x72b6bcf) [0x556e9ffd7bcf] (??:0)
[6] ClassDB::get_method_list(StringName const&, List<MethodInfo, DefaultAllocator>*, bool, bool) (??:0)
[7] DocTools::generate(bool) (??:0)
[8] EditorHelp::generate_doc() (??:0)
[9] EditorNode::EditorNode() (??:0)
[10] Main::start() (??:0)
[11] /home/nathan/workspace/public/godot/bin/godot.linuxbsd.tools.64.llvm(main+0x1c9) [0x556e9aeb8709] (??:0)
[12] /usr/lib/libc.so.6(+0x29290) [0x7fb8ac5a4290] (??:0)
[13] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7fb8ac5a434a] (??:0)
[14] /home/nathan/workspace/public/godot/bin/godot.linuxbsd.tools.64.llvm(_start+0x25) [0x556e9aeb8465] (??:0)
-- END OF BACKTRACE --
================================================================

Steps to reproduce

  1. Run scons in godot-cpp/test
  2. Open godot-cpp/test/demo in Godot

Minimal reproduction project

https://github.com/godotengine/godot-cpp/

@alessandrofama
Copy link
Contributor

alessandrofama commented Jun 16, 2022

On macOS I experience the same crash with a custom build (4bbe7f0, target=debug and target=release_debug, clang).

handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.alpha.custom_build (4bbe7f0b98de72d6dd77d5ade4b761de375bcf66)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] 1   libsystem_platform.dylib            0x00007ff811f21dfd _sigtramp + 29
[2] CowData<char32_t>::~CowData() (in godot) (cowdata.h:410)
[3] String::copy_from(char const*) (in godot) (ustring.cpp:314)
[4] String::operator=(char const*) (in godot) (ustring.cpp:451)
[5] NativeExtensionMethodBind::_gen_argument_type_info(int) const (in godot) (native_extension.cpp:60)
[6] MethodBind::get_return_info() const (in godot) (method_bind.cpp:77)
[7] info_from_bind(MethodBind*) (in godot) (class_db.cpp:412)
[8] ClassDB::get_method_list(StringName const&, List<MethodInfo, DefaultAllocator>*, bool, bool) (in godot) (class_db.cpp:451)
[9] DocTools::generate(bool) (in godot) (doc_tools.cpp:469)
[10] EditorHelp::generate_doc() (in godot) (editor_help.cpp:1782)
[11] EditorNode::EditorNode() (in godot) (editor_node.cpp:5886)
[12] EditorNode::EditorNode() (in godot) (editor_node.cpp:7272)
[13] Main::start() (in godot) (main.cpp:2410)
[14] main (in godot) (godot_main_osx.mm:90)
[15] 15  dyld                                0x00000001238f751e start + 462
-- END OF BACKTRACE --

I can run the test project with Godot Engine v4.0.alpha10.official.4bbe7f0b9 just fine. The only error (no crash) I have noticed occurs when I check the docs of the Example class:

Unicode parsing error: Invalid unicode codepoint ffffff89.
ERROR: U_ILLEGAL_ARGUMENT_ERROR
   at: ScriptIterator (modules/text_server_adv/script_iterator.cpp:71)

Seems like the void return type is missing for test_static2. The method will be called correctly when running the scene though.

Might be an unrelated error but wanted to include the info since it involves one of the static methods.

@alessandrofama
Copy link
Contributor

alessandrofama commented Jun 18, 2022

I think pinfo (GDNativePropertyInfo) is not initialized for static, no return methods when get_argument_info_func is called with p_arg == -1 (-1 indicating the return type of the method, if I understand it correctly?):

virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
GDNativePropertyInfo pinfo;
get_argument_info_func(method_userdata, p_arg, &pinfo);
PropertyInfo ret;
ret.type = Variant::Type(pinfo.type);
ret.name = pinfo.name;
ret.class_name = pinfo.class_name;
ret.hint = PropertyHint(pinfo.hint);
ret.usage = pinfo.usage;
ret.class_name = pinfo.class_name;
return ret;
}

ret (PropertyInfo) will get garbage values, like ret.type == TRANSFORM3D | 0xb73ece80, which should really be NIL for void, I think.

This does not happen with non-static methods, since pinfo gets some default values in the bindings (p_arg == -1): https://github.com/godotengine/godot-cpp/blob/40f5bfda226b71b629742c8314f2f175da7b523d/include/godot_cpp/core/method_bind.hpp#L290

Replacing the static no return version of gen_argument_type_info (method_bind.hpp in godot-cpp) with the no return version linked above, rebuilding the bindings lib and test project again fixes the crash and also shows the correct return type in the docs for me:

image

At least I think this is what's happening when I look at the debugger ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment