Skip to content

Crash on Godot 4.5 beta5 with gdextension built for Godot 4.2 #1832

@3ddelano

Description

@3ddelano

Godot version

v4.5.beta5.official (c81fd6c51233a727da528cf7f74137d56b5d6efe)

godot-cpp version

godot-4.2-stable

System information

macOS 15.6, Apple M3 Pro

Issue description

I have a gdextension built using godot-cpp (godot-4.2-stable) branch. When I open a project with the gdextension in Godot 4.5 beta5. the editor crashes with the following backtrace.

The crash below is of another GDExtension not the one from the minimum reproducible project.

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.5.beta5.official (c81fd6c51233a727da528cf7f74137d56b5d6efe)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[1] 1   libsystem_platform.dylib            0x000000018ea496a4 _sigtramp + 56
[2] 2   libgdextplugin.macos.temp 0x0000000112eba214 gdext_plugin_library_init + 109312
........
[9] Node::_notification(int) (in Godot) + 5208
[10] Object::_notification_forward(int) (in Godot) + 32
[11] SceneTree::_process_group(SceneTree::ProcessGroup*, bool) (in Godot) + 332
[12] SceneTree::_process(bool) (in Godot) + 896
[13] SceneTree::process(double) (in Godot) + 280
[14] Main::iteration() (in Godot) + 1024
[15] OS_MacOS_NSApp::start_main()
[16] 16  CoreFoundation                      0x000000018eaf9ed8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
[17] 17  CoreFoundation                      0x000000018eaf9dc0 __CFRunLoopDoObservers + 536
[18] 18  CoreFoundation                      0x000000018eaf94d0 __CFRunLoopRun + 944
[19] 19  CoreFoundation                      0x000000018eaf8a98 CFRunLoopRunSpecific + 572
[20] 20  HIToolbox                           0x000000019a59b27c RunCurrentEventLoopInMode + 324
[21] 21  HIToolbox                           0x000000019a59e4e8 ReceiveNextEventCommon + 676
[22] 22  HIToolbox                           0x000000019a729484 _BlockUntilNextEventMatchingListInModeWithFilter + 76
[23] 23  AppKit                              0x0000000192a1da34 _DPSNextEvent + 684
[24] 24  AppKit                              0x00000001933bc940 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
[25] 25  AppKit                              0x0000000192a10be4 -[NSApplication run] + 480
[26] main (in Godot) + 816
[27] 27  dyld                                0x000000018e66eb98 start + 6076
-- END OF C++ BACKTRACE --
================================================================
[1]    40630 abort      ./Godot -e --path ./project

Steps to reproduce

  1. Clone the below project
  2. Run the command
    scons dev_build=yes target=template_debug
  3. Open the project in demo folder in Godot 4.5 beta5 editor.
  4. You will see a new tab in the bottom container of the Editor called Example Dock, click that. In this dock there is a Print Hello button. On clicking that button the editor crashes. Which shouldn't happen, instead Hello from ExampleSingleton should be printed which is working fine in Godot 4.2.

Backtrace

godot::Node::get_name() const node.cpp:70
godot::ExampleSingleton::print_hello() const example_singleton.cpp:16
godot::ExampleEditorPlugin::_on_button_pressed() example_editor_plugin.cpp:11
godot::call_with_variant_args_static<…>(void (*)(), const godot::Variant **, GDExtensionCallError &, IndexSequence<…>) binder_common.hpp:544
godot::call_with_variant_args_static_ret<…>(void (*)(), const godot::Variant **, int, godot::Variant &, GDExtensionCallError &) binder_common.hpp:628
godot::CallableCustomStaticMethodPointer::call(const godot::Variant **, int, godot::Variant &, GDExtensionCallError &) const callable_method_pointer.hpp:186
godot::custom_callable_mp_call(void *, const void *const *, long long, void *, GDExtensionCallError *) callable_method_pointer.cpp:39
<unknown> 0x00000001055744d0
Object::emit_signalp(const StringName &, const Variant **, int) 0x0000000106f2d3e0
BaseButton::_pressed() 0x00000001036b7b68
BaseButton::on_action_event(Ref<…>) 0x00000001036b73f8
BaseButton::gui_input(const Ref<…> &) 0x00000001036b71ac
Control::_call_gui_input(const Ref<…> &) 0x0000000103754310
Viewport::_gui_call_input(Control *, const Ref<…> &) 0x0000000103644e3c
Viewport::_gui_input_event(Ref<…>) 0x00000001036459d8
Viewport::push_input(const Ref<…> &, bool) 0x000000010364b8a0
Window::_window_input(const Ref<…> &) 0x0000000103688028
<unknown> 0x0000000101b0ed74
<unknown> 0x00000001011d2090
DisplayServerMacOS::_dispatch_input_event(const Ref<…> &) 0x00000001011d1bf0
Input::_parse_input_event_impl(const Ref<…> &, bool) 0x00000001051d84a4
Input::flush_buffered_events() 0x00000001051d6024
DisplayServerMacOS::_process_events(bool) 0x00000001011e5c74
<unknown> 0x00000001011bf304
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 0x000000018eaf9ed8
__CFRunLoopDoObservers 0x000000018eaf9dc0
__CFRunLoopRun 0x000000018eaf94d0
CFRunLoopRunSpecific 0x000000018eaf8a98
RunCurrentEventLoopInMode 0x000000019a59b27c
ReceiveNextEventCommon 0x000000019a59e4e8
_BlockUntilNextEventMatchingListInModeWithFilter 0x000000019a729484
_DPSNextEvent 0x0000000192a1da34
-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] 0x00000001933bc940
-[NSApplication run] 0x0000000192a10be4
main 0x00000001011fd9c8
start 0x000000018e66eb98

My hypothesis: I think the issue is because the ExampleSingleton is already freed by the EditorHelp::_gen_extensions_doc() > DocTools::generate > ... See below stack, so the ExampleSingleton::get_singleton() returns nullptr on Godot 4.5 beta5 but not on Godot 4.2 stable.

godot::ExampleSingleton::~ExampleSingleton() example_singleton.h:18
godot::ExampleSingleton::free(void *, void *) example_singleton.h:11
Object::~Object() 0x0000000104ddced4
ClassDB::class_get_default_property_value(const StringName &, const StringName &, bool *) 0x0000000104dc1904
<unknown> 0x00000001020dbd48
DocTools::generate(BitField<…>) 0x00000001020d5fc0
EditorHelp::_gen_extensions_docs() 0x0000000102114afc
CallQueue::_call_function(const Callable &, const Variant *, int, bool) 0x0000000104dcad48
CallQueue::flush() 0x0000000104dcb030
SceneTree::physics_process(double) 0x0000000102e31310
Main::iteration() 0x0000000100a67654
<unknown> 0x00000001009db32c
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 0x000000018eaf9ed8
__CFRunLoopDoObservers 0x000000018eaf9dc0
__CFRunLoopRun 0x000000018eaf94d0
CFRunLoopRunSpecific 0x000000018eaf8a98
RunCurrentEventLoopInMode 0x000000019a59b27c
ReceiveNextEventCommon 0x000000019a59e4e8
_BlockUntilNextEventMatchingListInModeWithFilter 0x000000019a729484
_DPSNextEvent 0x0000000192a1da34
-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] 0x00000001933bc940
-[NSApplication run] 0x0000000192a10be4
main 0x0000000100a199c8
start 0x000000018e66eb98

Minimal reproduction project

https://github.com/3ddelano/godot45beta5_issue_with_opening_gdext_for_godot42

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis has been identified as a bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions