Skip to content

Editor crashes when calling virtual functions from classes that inherit from abstract classes #1873

Closed

Description

@xana43

Godot version

v4.5.2.rc.custom_build (8351a28101ff0b4b7e4c27690b34c1ee2e2330e9)

godot-cpp version

4.5-stable abe9457

System information

Fedora 42, AMD Ryzen 9 7950x

Issue description

after the latest cherrypicks loading the extension in the editor causes a crash around the time it's calling setup on the gui. here's the stack trace

godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:136:34: runtime error: reference binding to null pointer of type 'const struct HashMapData'
godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:136:15: runtime error: load of null pointer of type 'const struct HashMapData'

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.5.2.rc.custom_build (8351a28101ff0b4b7e4c27690b34c1ee2e2330e9)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[1] /lib64/libc.so.6(+0x1a070) [0x7f3f28fca070] (??:0)
[2] godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::_lookup_pos_with_hash(godot::StringName const&, unsigned int&, unsigned int&, unsigned int) const (??:0)
[3] godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::_lookup_pos(godot::StringName const&, unsigned int&, unsigned int&) const (??:0)
[4] godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::find(godot::StringName const&) const (??:0)
[5] godot::ClassDB::get_virtual_func(void*, void const*, unsigned int) (??:0)
[6] Control::_gdvirtual__get_minimum_size_call(Vector2&) const (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.h:401 (discriminator 54))
[7] Control::get_minimum_size() const (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:1686)
[8] Control::_update_minimum_size_cache() const (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:1712)
[9] Control::get_combined_minimum_size() const (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:1722)
[10] TabContainer::get_minimum_size() const (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/tab_container.cpp:975)
[11] Control::_update_minimum_size_cache() const (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:1712)
[12] Control::get_combined_minimum_size() const (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:1722)
[13] Control::_size_changed() (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:1740)
[14] Control::_notification(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:3930)
[15] Control::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.h:46 (discriminator 12))
[16] Container::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/container.h:36)
[17] TabContainer::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/tab_container.h:38)
[18] Object::_notification_forward(int) (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.cpp:931)
[19] ThemeOwner::_owner_context_changed() (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.h:893)
[20] ThemeOwner::set_owner_context(ThemeContext*, bool) (/home/jwoon/Documents/GodotTemplates/godot/scene/theme/theme_owner.cpp:87)
[21] Control::set_theme_context(ThemeContext*, bool) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:2926)
[22] Control::_notification(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.cpp:3801 (discriminator 2))
[23] Control::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/control.h:46 (discriminator 12))
[24] Container::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/container.h:36)
[25] TabContainer::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/gui/tab_container.h:38)
[26] Object::_notification_forward(int) (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.cpp:931)
[27] Node::_propagate_enter_tree() (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.h:893)
[28] Node::_propagate_enter_tree() (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.cpp:360)
[29] Node::_propagate_enter_tree() (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.cpp:360)
[30] Node::_propagate_enter_tree() (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.cpp:360)
[31] Node::_set_tree(SceneTree*) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.cpp:3319)
[32] Node::_add_child_nocheck(Node*, StringName const&, Node::InternalMode) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.cpp:1670)
[33] Node::add_child(Node*, bool, Node::InternalMode) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.cpp:1700)
[34] EditorNode::set_edited_scene_root(Node*, bool) (/home/jwoon/Documents/GodotTemplates/godot/editor/editor_node.cpp:4161)
[35] EditorNode::set_edited_scene(Node*) (/home/jwoon/Documents/GodotTemplates/godot/editor/editor_node.cpp:4140)
[36] EditorNode::load_scene(String const&, bool, bool, bool, bool) (/home/jwoon/Documents/GodotTemplates/godot/editor/editor_node.cpp:4479)
[37] EditorNode::_load_open_scenes_from_config(Ref<ConfigFile>) (/home/jwoon/Documents/GodotTemplates/godot/editor/editor_node.cpp:5870 (discriminator 2))
[38] EditorNode::_load_editor_layout() (/home/jwoon/Documents/GodotTemplates/godot/editor/editor_node.cpp:5766 (discriminator 3))
[39] EditorNode::_sources_changed(bool) (/home/jwoon/Documents/GodotTemplates/godot/editor/editor_node.cpp:1368)
[40] void call_with_variant_args_helper<EditorNode, bool, 0ul>(EditorNode*, void (EditorNode::*)(bool), Variant const**, Callable::CallError&, IndexSequence<0ul>) (/home/jwoon/Documents/GodotTemplates/godot/core/variant/binder_common.h:223 (discriminator 5))
[41] void call_with_variant_args<EditorNode, bool>(EditorNode*, void (EditorNode::*)(bool), Variant const**, int, Callable::CallError&) (/home/jwoon/Documents/GodotTemplates/godot/core/variant/binder_common.h:337)
[42] CallableCustomMethodPointer<EditorNode, void, bool>::call(Variant const**, int, Variant&, Callable::CallError&) const (/home/jwoon/Documents/GodotTemplates/godot/core/object/callable_method_pointer.h:103)
[43] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (/home/jwoon/Documents/GodotTemplates/godot/core/variant/callable.cpp:57)
[44] Object::emit_signalp(StringName const&, Variant const**, int) (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.cpp:1297)
[45] Node::emit_signalp(StringName const&, Variant const**, int) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.cpp:4139)
[46] Error Object::emit_signal<bool>(StringName const&, bool) (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.h:944)
[47] EditorFileSystem::_notification(int) (/home/jwoon/Documents/GodotTemplates/godot/editor/file_system/editor_file_system.cpp:1796 (discriminator 4))
[48] EditorFileSystem::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/editor/file_system/editor_file_system.h:148 (discriminator 12))
[49] Object::_notification_forward(int) (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.cpp:931)
[50] SceneTree::_process_group(SceneTree::ProcessGroup*, bool) (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.h:893)
[51] SceneTree::_process(bool) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/scene_tree.cpp:1279 (discriminator 1))
[52] SceneTree::process(double) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/scene_tree.cpp:706)
[53] Main::iteration() (/home/jwoon/Documents/GodotTemplates/godot/main/main.cpp:4802 (discriminator 4))
[54] OS_LinuxBSD::run() (/home/jwoon/Documents/GodotTemplates/godot/platform/linuxbsd/os_linuxbsd.cpp:989)
[55] /mnt/Forerunner/SteamLibrary/steamapps/common/Godot Engine/godot.x11.opt.tools.64(main+0x2b6) [0x56186e706d1f] (/home/jwoon/Documents/GodotTemplates/godot/platform/linuxbsd/godot_linuxbsd.cpp:85)
[56] /lib64/libc.so.6(+0x3575) [0x7f3f28fb3575] (??:0)
[57] /lib64/libc.so.6(__libc_start_main+0x88) [0x7f3f28fb3628] (??:0)
[58] /mnt/Forerunner/SteamLibrary/steamapps/common/Godot Engine/godot.x11.opt.tools.64(_start+0x25) [0x56186e7069a5] (??:?)
-- END OF C++ BACKTRACE --
================================================================

Steps to reproduce

get the latest cherry picks, try to load a project with it. experience crash

Minimal reproduction project

N/A

Activity

  1. xana43 commented on Oct 23, 2025

    @xana43
    Author

    I have confirmed that this issue does not exist when using verson of godot-cpp before this commit

  2. Ivorforce commented on Oct 23, 2025

    @Ivorforce
    Member

    Hi! Sorry about the trouble. We had a similar issue a couple of weeks ago (#1862) that has been worked around, but not necessarily solved.

    It's unfortunately difficult to solve the issue without a minimal reproduction project, so please provide one and I'll have a look.

  3. xana43 commented on Oct 23, 2025

    @xana43
    Author

    Hi! Sorry about the trouble. We had a similar issue a couple of weeks ago (#1862) that has been worked around, but not necessarily solved.

    It's unfortunately difficult to solve the issue without a minimal reproduction project, so please provide one and I'll have a look.

    creating a minimal reproduction project is taking longer than expected. When I create a minimal reproduction project using all of the supposed recreation criteria in issue #1862 the issue doesn't occur at all in the minimal reproduction project. However in my main project it happens every time. I tried to remove classes that rely on such class hierarchy, and i've also removed certain utility classes that I made that load and do operations before the editor has a chance to set up the gui, and the issue still remains. I've tried to run a debugger to see what other information I can gather, but so far no results have turned up. I will keep trying to make a reproduction project in the mean time.

  4. Ivorforce commented on Oct 23, 2025

    @Ivorforce
    Member

    Thanks for putting in the time for it, I appreciate it! Note that the user in #1862 was also unable to pinpoint the exact issue. It's possible that this only occurs in some very specific setups, which are currently unexpected in other ways (for example, recursive AHashMap access?).

    Anyway, if you manage to find out more, let me know!

  5. added
    bug
    on Oct 23, 2025
  6. xana43 commented on Oct 24, 2025

    @xana43
    Author

    I did find out something else that I think it relevant to this issue. When I change the order of when my classes are registered, the part of the code that it fails on changes. in my prior setup when I first found this, I had a class that represented my options menu registered after the sub-components of said option menu.

    I moved it to be registered before the other options (as the new implementation is AHashMap I thought that order would play a role in this) but now instead of it crashing when it's trying to load UI, it's crashing when it's trying to load a character within my game (in this case it's a test enemy in 2D) and it always happens when the scene tree is sending out the "tree_entered" signal to all nodes (it's also trying to open up multiple scenes at once as it's trying to restore my last saved editor layout)

    I am unsure still what is causing this issue, because nothing in any stack traces or anything is pointing to my singletons, or anything else besides nodes that load up when the scene is loaded in general. I have tried to set everything up the same way in reproduction projects. but nothing happens

    I've tried making singletons, abstract classes that register the overridden functions in derived classes, multi-level inerhitance with some classes randomly being abstract, nothing happens. perhaps it might be due to the fact that in my main project like 5 scenes open at once. I can only assume this is a threading issue (assuming that opening scenes is a multi-threaded operation) because to me this feels like undefined behavior in some way shape or form

    under a debugger, I have also determined a potential place for investigation, while the classDB is calling virtual funtions, repeatedly a function in AHashMap called _lookup_pos_with_hash is called, putting a breakpoint and running it until it crashes indicates that for some reason, map_data, capacity, num_elements are all empty, with map_data being NULL however, it's being de-referenced anyways at this point. It's not always null, there are multiple virtual functions that get called successfully, for some reason though it only seems to fail when a class inherits from a class marked as abstract. according to the data from the call to the virtual function _get_minimum_size() though the bindings, something happens (I can't debug this because the call across the bindings is an opaque pointer) once it gets over to the AHashMap implementation the key is nothing and the data is null.

    However debugging this using the godot source code as a reference and not the godot-cpp source code (I use CLion for debugging and it takes the current "project" that's open for debug symbols). There is a valid key within the AHashMap on the godot side, but for some reason I can't step through ClassDB::get_virtual_func() so I am unsure if the virtual function macro present in control.h is even sending the right data.

    HashMapData *map_data = nullptr;
    
    //other code here
    
    
    bool _lookup_pos_with_hash(const TKey &p_key, uint32_t &r_pos, uint32_t &r_hash_pos, uint32_t p_hash) const {
    		if (unlikely(elements == nullptr)) {
    			return false; // Failed lookups, no elements.
    		}
    
    		uint32_t pos = p_hash & capacity;
    		HashMapData data = map_data[pos]; //dereferencing a nullptr
    		if (data.hash == p_hash && Comparator::compare(elements[data.hash_to_key].key, p_key)) {
    			r_pos = data.hash_to_key;
    			r_hash_pos = pos;
    			return true;
    		}
    
    		if (data.data == EMPTY_HASH) {
    			return false;
    		}
    //rest of the function down here

    here's the reproduction project I've been trying to get working in case it helps

    Reproduction project.zip

    this might be the limits of what I can find, because every debugger I try can't really see what data is being sent between the bindings, the only thing I know is that. For classes not marked as abstract it works fine.

  7. changed the title [-]Editor crashes due to AHashMap during gui setup[/-] [+]Editor crashes due to AHashMap when calling virtual functions from classes that inherit from abstract classes[/+] on Oct 24, 2025
  8. changed the title [-]Editor crashes due to AHashMap when calling virtual functions from classes that inherit from abstract classes[/-] [+]Editor crashes when calling virtual functions from classes that inherit from abstract classes[/+] on Oct 24, 2025
  9. BenLubar commented on Oct 25, 2025

    @BenLubar
    Contributor

    Not by any means a "minimal" repro case, but there's a reproducible crash here:
    https://git.lubar.me/ben/spy-cards/src/commit/8dd5cc94083ca786c134f642bdafebc28ab5187b/build.sh#L26

    (where godot-latest is the 4.6-dev2 Linux executable)

    Here's the stack trace: (godot-dev is the same engine commit built locally with debug symbols)

    Thread 1 "godot-dev" received signal SIGSEGV, Segmentation fault.
    godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::_lookup_pos_with_hash (this=0x555564c37158, 
        p_key=..., r_pos=@0x7fffffff9c10: 0, r_hash_pos=@0x7fffffff9c14: 0, p_hash=3938519247) at godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:136
    136                     HashMapData data = map_data[pos];
    (gdb) bt
    #0  godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::_lookup_pos_with_hash (this=0x555564c37158, 
        p_key=..., r_pos=@0x7fffffff9c10: 0, r_hash_pos=@0x7fffffff9c14: 0, p_hash=3938519247) at godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:136
    #1  0x00007fffa121c41a in godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::_lookup_pos (
        this=0x555564c37158, p_key=..., r_pos=@0x7fffffff9c10: 0, r_hash_pos=@0x7fffffff9c14: 0) at godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:127
    #2  0x00007fffa121afcf in godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::find (
        this=0x555564c37158, p_key=...) at godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:579
    #3  0x00007fffa121839a in godot::ClassDB::get_virtual_func (p_userdata=0x7fffa175efc0 <RichText::get_class_static()::string_name>, 
        p_name=0x55556344ce68 <Resource::_gdvirtual__set_path_cache_call(String) const::_gdvirtual__set_path_cache_sn>, p_hash=3089850668) at godot-cpp/src/core/class_db.cpp:300
    #4  0x000055555e9cc136 in Object::_gdvirtual_init_method_ptr (this=0x555585882c60, p_compat_hash=3089850668, r_fn_ptr=@0x555585882e10: 0x0, p_fn_name=..., p_compat=false) at core/object/object.cpp:967
    #5  0x000055555e4bc4db in Resource::_gdvirtual__set_path_cache_call (this=0x555585882c60, arg1=...) at core/io/resource.h:121
    #6  0x000055555e4b718f in Resource::set_path_cache (this=0x555585882c60, p_path=...) at core/io/resource.cpp:115
    #7  0x000055555d1743fb in ResourceLoaderText::load (this=0x7fffffffa100) at scene/resources/resource_format_text.cpp:606
    #8  0x000055555d1794dc in ResourceFormatLoaderText::load (this=0x555563f0bc00, p_path=..., p_original_path=..., r_error=0x7fffffffc394, p_use_sub_threads=false, r_progress=0x5555856b2018, 
        p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE) at scene/resources/resource_format_text.cpp:1434
    #9  0x000055555e4e0c18 in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE, r_error=0x7fffffffc394, p_use_sub_threads=false, 
        r_progress=0x5555856b2018) at core/io/resource_loader.cpp:314
    #10 0x000055555e4e13b2 in ResourceLoader::_run_load_task (p_userdata=0x5555856b1fd8) at core/io/resource_loader.cpp:396
    #11 0x000055555e4e25ba in ResourceLoader::_load_start (p_path=..., p_type_hint=..., p_thread_mode=ResourceLoader::LOAD_THREAD_FROM_CURRENT, p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE, 
        p_for_user=false) at core/io/resource_loader.cpp:660
    #12 0x000055555e4e1df0 in ResourceLoader::load (p_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE, r_error=0x0) at core/io/resource_loader.cpp:554
    #13 0x000055555b179d26 in EditorExportPlatform::_export_customize (this=0x555565500490, p_path=..., customize_resources_plugins=..., customize_scenes_plugins=..., export_cache=..., export_base_path=..., 
        p_force_save=true) at editor/export/editor_export_platform.cpp:923
    #14 0x000055555b17f396 in EditorExportPlatform::export_project_files (this=0x555565500490, p_preset=..., p_debug=true, 
        p_save_func=0x55555b175ab6 <EditorExportPlatform::_save_pack_file(void*, String const&, Vector<unsigned char> const&, int, int, Vector<String> const&, Vector<String> const&, Vector<unsigned char> const&, unsigned long)>, p_remove_func=0x0, p_udata=0x7fffffffcd30, p_so_func=0x55555b180a7c <EditorExportPlatform::_pack_add_shared_object(void*, SharedObject const&)>)
        at editor/export/editor_export_platform.cpp:1525
    #15 0x000055555b183a16 in EditorExportPlatform::save_pack (this=0x555565500490, p_preset=..., p_debug=true, p_path=..., p_so_files=0x7fffffffceb0, 
        p_save_func=0x55555b175ab6 <EditorExportPlatform::_save_pack_file(void*, String const&, Vector<unsigned char> const&, int, int, Vector<String> const&, Vector<String> const&, Vector<unsigned char> const&, unsigned long)>, p_remove_func=0x0, p_embed=false, r_embedded_start=0x0, r_embedded_size=0x0) at editor/export/editor_export_platform.cpp:2091
    #16 0x000055555bd4c1b4 in EditorExportPlatformWeb::export_project (this=0x555565500490, p_preset=..., p_debug=true, p_path=..., p_flags=...) at platform/web/export/export_plugin.cpp:520
    #17 0x000055555ade2e97 in EditorNode::_fs_changed (this=0x555565428880) at editor/editor_node.cpp:1284
    #18 0x000055555ae5cd18 in call_with_variant_args_helper<EditorNode>(EditorNode*, void (EditorNode::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (p_instance=0x555565428880, 
        p_method=(void (EditorNode::*)(EditorNode * const)) 0x55555ade2344 <EditorNode::_fs_changed()>, p_args=0x0, r_error=...) at ./core/variant/binder_common.h:223
    #19 0x000055555ae5be3c in call_with_variant_args<EditorNode> (p_instance=0x555565428880, p_method=(void (EditorNode::*)(EditorNode * const)) 0x55555ade2344 <EditorNode::_fs_changed()>, p_args=0x0, 
        p_argcount=0, r_error=...) at ./core/variant/binder_common.h:337
    #20 0x000055555ae5b117 in CallableCustomMethodPointer<EditorNode, void>::call (this=0x55557709cb00, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...)
        at ./core/object/callable_method_pointer.h:103
    #21 0x000055555e5bd44e in Callable::callp (this=0x7fffffffd310, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...) at core/variant/callable.cpp:57
    #22 0x000055555e9ce463 in Object::emit_signalp (this=0x5555654c67a0, p_name=..., p_args=0x0, p_argcount=0) at core/object/object.cpp:1341
    #23 0x000055555c1929f1 in Node::emit_signalp (this=0x5555654c67a0, p_name=..., p_args=0x0, p_argcount=0) at scene/main/node.cpp:4166
    #24 0x0000555559085fca in Object::emit_signal<>(StringName const&) (this=0x5555654c67a0, p_name=...) at ./core/object/object.h:967
    #25 0x000055555b22120f in EditorFileSystem::_notification (this=0x5555654c67a0, p_what=17) at editor/file_system/editor_file_system.cpp:1795
    #26 0x000055555b233492 in EditorFileSystem::_notification_forwardv (this=0x5555654c67a0, p_notification=17) at editor/file_system/editor_file_system.h:148
    #27 0x000055555e9cc317 in Object::_notification_forward (this=0x5555654c67a0, p_notification=17) at core/object/object.cpp:993
    #28 0x0000555558c929d8 in Object::notification (this=0x5555654c67a0, p_notification=17, p_reversed=false) at ./core/object/object.h:919
    #29 0x000055555c1ca335 in SceneTree::_process_group (this=0x55556542dd40, p_group=0x55556542df60, p_physics=false) at scene/main/scene_tree.cpp:1202
    #30 0x000055555c1ca91e in SceneTree::_process (this=0x55556542dd40, p_physics=false) at scene/main/scene_tree.cpp:1279
    #31 0x000055555c1c83ec in SceneTree::process (this=0x55556542dd40, p_time=0.0068970000000000004) at scene/main/scene_tree.cpp:706
    #32 0x0000555558d852bf in Main::iteration () at main/main.cpp:4748
    #33 0x0000555558c9aa0e in OS_LinuxBSD::run (this=0x7fffffffd850) at platform/linuxbsd/os_linuxbsd.cpp:991
    #34 0x0000555558cb0bf0 in main (argc=5, argv=0x7fffffffde88) at platform/linuxbsd/godot_linuxbsd.cpp:85
    

    some potentially useful variable values:

    (gdb) p this
    $2 = (const godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> > * const) 0x555564c37158
    (gdb) p *this
    $3 = {static INITIAL_CAPACITY = <optimized out>, static EMPTY_HASH = <optimized out>, elements = 0x555564c33660, map_data = 0x0, capacity = 65, num_elements = 0}
    
  10. xana43 commented on Oct 25, 2025

    @xana43
    Author

    a few more bits of information that I've discovered while messing around some more. so I here's some of the example of what my set up looks like (in a way that I can disclose)

    I have an abstract class named Pawn this contains all of the base code for living entities, it inherits CharacterBody2D and contains 2 virtual functions named damage and heal both of these take a real_t for the amount of health to add or remove, there's other methods that are bound as well but these are not important, the ones that are important are the virtrual functions and how they're registered (assuming I'm understanding the issue here)

    I have 2 divergent branches from this class (which is marked as an abstract class)

    I have a class named PartyMember which is the player's characters (as i'm currently developing a 2D RPG game) scenes with this class function fine until I add a GDScript to it, this class doesn't override the virtual functions from Pawn as those are virtual functions with implementations (not a pure virtual) the only other thing of interest in this class is that it defined _set() _get() and _get_property_list() but these don't cause issues.

    when I add a GDScript to PartyMember I get this stack trace

    src/cereberal/beings/partymember.cpp:523:63: runtime error: member call on null pointer of type 'struct Input'
    src/cereberal/beings/partymember.cpp:523:63: runtime error: member access within null pointer of type 'struct Input'
    
    ================================================================
    handle_crash: Program crashed with signal 11
    Engine version: Godot Engine v4.5.2.rc.custom_build (8351a28101ff0b4b7e4c27690b34c1ee2e2330e9)
    Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
    [1] /lib64/libc.so.6(+0x1a070) [0x7fd6a978b070] (??:0)
    [2] godot::PartyMember::_physics_process(double) (??:0)
    [3] void godot::call_with_ptr_args_helper<godot::PartyMember, double, 0ul>(godot::PartyMember*, void (godot::PartyMember::*)(double), void const* const*, godot::IndexSequence<0ul>) (??:0)
    [4] void godot::call_with_ptr_args<godot::PartyMember, double>(godot::PartyMember*, void (godot::PartyMember::*)(double), void const* const*, void*) (??:0)
    [5] godot::Node::register_virtuals<godot::PartyMember, godot::Pawn>()::{lambda(void*, void const* const*, void*)#1}::operator()(void*, void const* const*, void*) const (??:0)
    [6] godot::Node::register_virtuals<godot::PartyMember, godot::Pawn>()::{lambda(void*, void const* const*, void*)#1}::_FUN(void*, void const* const*, void*) (??:0)
    [7] Node::_gdvirtual__physics_process_call(double) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.h:396 (discriminator 88))
    [8] Node::_notification(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.cpp:87 (discriminator 1))
    [9] Node::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/node.h:48 (discriminator 12))
    [10] CanvasItem::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/canvas_item.h:43)
    [11] Node2D::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/2d/node_2d.h:36)
    [12] CollisionObject2D::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/2d/physics/collision_object_2d.h:39)
    [13] PhysicsBody2D::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/2d/physics/physics_body_2d.h:39)
    [14] CharacterBody2D::_notification_forwardv(int) (/home/jwoon/Documents/GodotTemplates/godot/scene/2d/physics/character_body_2d.h:37)
    [15] Object::_notification_forward(int) (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.cpp:931)
    [16] SceneTree::_process_group(SceneTree::ProcessGroup*, bool) (/home/jwoon/Documents/GodotTemplates/godot/core/object/object.h:893)
    [17] SceneTree::_process(bool) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/scene_tree.cpp:1279 (discriminator 1))
    [18] SceneTree::physics_process(double) (/home/jwoon/Documents/GodotTemplates/godot/scene/main/scene_tree.cpp:642)
    [19] Main::iteration() (/home/jwoon/Documents/GodotTemplates/godot/main/main.cpp:4747 (discriminator 4))
    [20] OS_LinuxBSD::run() (/home/jwoon/Documents/GodotTemplates/godot/platform/linuxbsd/os_linuxbsd.cpp:989)
    [21] /mnt/Forerunner/SteamLibrary/steamapps/common/Godot Engine/godot.x11.opt.tools.64(main+0x2b6) [0x5638e3d98d1f] (/home/jwoon/Documents/GodotTemplates/godot/platform/linuxbsd/godot_linuxbsd.cpp:85)
    [22] /lib64/libc.so.6(+0x3575) [0x7fd6a9774575] (??:0)
    [23] /lib64/libc.so.6(__libc_start_main+0x88) [0x7fd6a9774628] (??:0)
    [24] /mnt/Forerunner/SteamLibrary/steamapps/common/Godot Engine/godot.x11.opt.tools.64(_start+0x25) [0x5638e3d989a5] (??:?)
    -- END OF C++ BACKTRACE --
    ================================================================
    
    

    this issue goes completely away when I remove the GDScript from this class

    the other divergent tree that comes from Pawn is NPCs

    it now goes

    Pawn -> Npc -> Enemy

    Npc does actually override the damage() function from Pawn because it's so generic I can share the implementation of this function

    void damage(const real_t amount) override
            {
                Pawn::damage(amount);
                if (getHealth() <= 0)
                {
                    queue_free();
                }
            }

    this class also defines 2 more virtual functions that have a default implementation, not important here because Enemy doesn't override these

    when any scene with an Enemy present is opened, it causes a similar stack trace, erroring out at a gdvirtual##m_name##_call on the bindings. the same happens for my original issue, where there I have a class hierarchy like this

    base class: OptionPanel
    
    derived classes:
    AudioPanel,
    GraphicsPanel,
    GamePlayPanel
    

    however these crash without any GDScript attached to them at all.

    I found an issue that seems to be somewhat related

    godotengine/godot#106271

    when I get the chance to I might copy these all into another project and see if it still has an issue

  11. Ivorforce commented on Oct 25, 2025

    @Ivorforce
    Member

    Thank you @xana43 and @BenLubar.
    It appears you are both experiencing the issue: AHashMap (ClassInfo::virtual_methods) is found in an invalid state where elements != nullptr but map_data == nullptr. This leads to find crashing because it's dereferencing data that does not exist.

    I've looked at the source code, but cannot find a normal situation where I can see this happen.
    Some ideas though:

    • Memory::alloc_static returns nullptr when setting map_data. This would be possible if the requested size is too large, but this should log an error before the crash (did you see any?).
    • ClassDB is modified from two different threads. It seems not to be protected, but registering virtual methods is not expected to be done outside the main thread. Are either of you launching threads?
    • Something else is accidentally writing the memory that ClassInfo::virtual_methods is in, overriding elements. However, elements looks to be a relatively normal pointer in @BenLubar's trace, so this may be unlikely.

    If i could reproduce the problem, I would probably attempt to place breakpoints into bind_virtual_method and see when and how it happens that virtual_methods's elements is set to something other than nullptr, but map_data isn't.

    One observation: All three of you are using Linux. Perhaps this has something to do with a compiler or stdlib bug? This would be pretty obscure, but it's a possibility until someone reports the bug from another OS.

  12. xana43 commented on Oct 26, 2025

    @xana43
    Author

    I've done some testing with other compilers, I haven't had the chance to set up a test on MSVC, but the problem still persists on Clang/LLVM. I am not launching any threads at all though so I'm unsure why it seems to be doing this.

    I'd be willing to test on windows, but it'll take a while for that to be set up (I have a windows 10 VM, but it's a pain to install GCC on it)

    it's unlikely, but there's also a non-zero chance that an update to glibc/glibc++ and/or the linux kernel may have changed something about the threading priorities (as the editor itself may be doing something like that)

  13. xana43 commented on Oct 26, 2025

    @xana43
    Author

    Not by any means a "minimal" repro case, but there's a reproducible crash here: https://git.lubar.me/ben/spy-cards/src/commit/8dd5cc94083ca786c134f642bdafebc28ab5187b/build.sh#L26

    (where godot-latest is the 4.6-dev2 Linux executable)

    Here's the stack trace: (godot-dev is the same engine commit built locally with debug symbols)

    Thread 1 "godot-dev" received signal SIGSEGV, Segmentation fault.
    godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::_lookup_pos_with_hash (this=0x555564c37158, 
        p_key=..., r_pos=@0x7fffffff9c10: 0, r_hash_pos=@0x7fffffff9c14: 0, p_hash=3938519247) at godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:136
    136                     HashMapData data = map_data[pos];
    (gdb) bt
    #0  godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::_lookup_pos_with_hash (this=0x555564c37158, 
        p_key=..., r_pos=@0x7fffffff9c10: 0, r_hash_pos=@0x7fffffff9c14: 0, p_hash=3938519247) at godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:136
    #1  0x00007fffa121c41a in godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::_lookup_pos (
        this=0x555564c37158, p_key=..., r_pos=@0x7fffffff9c10: 0, r_hash_pos=@0x7fffffff9c14: 0) at godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:127
    #2  0x00007fffa121afcf in godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> >::find (
        this=0x555564c37158, p_key=...) at godot-cpp/include/godot_cpp/templates/a_hash_map.hpp:579
    #3  0x00007fffa121839a in godot::ClassDB::get_virtual_func (p_userdata=0x7fffa175efc0 <RichText::get_class_static()::string_name>, 
        p_name=0x55556344ce68 <Resource::_gdvirtual__set_path_cache_call(String) const::_gdvirtual__set_path_cache_sn>, p_hash=3089850668) at godot-cpp/src/core/class_db.cpp:300
    #4  0x000055555e9cc136 in Object::_gdvirtual_init_method_ptr (this=0x555585882c60, p_compat_hash=3089850668, r_fn_ptr=@0x555585882e10: 0x0, p_fn_name=..., p_compat=false) at core/object/object.cpp:967
    #5  0x000055555e4bc4db in Resource::_gdvirtual__set_path_cache_call (this=0x555585882c60, arg1=...) at core/io/resource.h:121
    #6  0x000055555e4b718f in Resource::set_path_cache (this=0x555585882c60, p_path=...) at core/io/resource.cpp:115
    #7  0x000055555d1743fb in ResourceLoaderText::load (this=0x7fffffffa100) at scene/resources/resource_format_text.cpp:606
    #8  0x000055555d1794dc in ResourceFormatLoaderText::load (this=0x555563f0bc00, p_path=..., p_original_path=..., r_error=0x7fffffffc394, p_use_sub_threads=false, r_progress=0x5555856b2018, 
        p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE) at scene/resources/resource_format_text.cpp:1434
    #9  0x000055555e4e0c18 in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE, r_error=0x7fffffffc394, p_use_sub_threads=false, 
        r_progress=0x5555856b2018) at core/io/resource_loader.cpp:314
    #10 0x000055555e4e13b2 in ResourceLoader::_run_load_task (p_userdata=0x5555856b1fd8) at core/io/resource_loader.cpp:396
    #11 0x000055555e4e25ba in ResourceLoader::_load_start (p_path=..., p_type_hint=..., p_thread_mode=ResourceLoader::LOAD_THREAD_FROM_CURRENT, p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE, 
        p_for_user=false) at core/io/resource_loader.cpp:660
    #12 0x000055555e4e1df0 in ResourceLoader::load (p_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE, r_error=0x0) at core/io/resource_loader.cpp:554
    #13 0x000055555b179d26 in EditorExportPlatform::_export_customize (this=0x555565500490, p_path=..., customize_resources_plugins=..., customize_scenes_plugins=..., export_cache=..., export_base_path=..., 
        p_force_save=true) at editor/export/editor_export_platform.cpp:923
    #14 0x000055555b17f396 in EditorExportPlatform::export_project_files (this=0x555565500490, p_preset=..., p_debug=true, 
        p_save_func=0x55555b175ab6 <EditorExportPlatform::_save_pack_file(void*, String const&, Vector<unsigned char> const&, int, int, Vector<String> const&, Vector<String> const&, Vector<unsigned char> const&, unsigned long)>, p_remove_func=0x0, p_udata=0x7fffffffcd30, p_so_func=0x55555b180a7c <EditorExportPlatform::_pack_add_shared_object(void*, SharedObject const&)>)
        at editor/export/editor_export_platform.cpp:1525
    #15 0x000055555b183a16 in EditorExportPlatform::save_pack (this=0x555565500490, p_preset=..., p_debug=true, p_path=..., p_so_files=0x7fffffffceb0, 
        p_save_func=0x55555b175ab6 <EditorExportPlatform::_save_pack_file(void*, String const&, Vector<unsigned char> const&, int, int, Vector<String> const&, Vector<String> const&, Vector<unsigned char> const&, unsigned long)>, p_remove_func=0x0, p_embed=false, r_embedded_start=0x0, r_embedded_size=0x0) at editor/export/editor_export_platform.cpp:2091
    #16 0x000055555bd4c1b4 in EditorExportPlatformWeb::export_project (this=0x555565500490, p_preset=..., p_debug=true, p_path=..., p_flags=...) at platform/web/export/export_plugin.cpp:520
    #17 0x000055555ade2e97 in EditorNode::_fs_changed (this=0x555565428880) at editor/editor_node.cpp:1284
    #18 0x000055555ae5cd18 in call_with_variant_args_helper<EditorNode>(EditorNode*, void (EditorNode::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (p_instance=0x555565428880, 
        p_method=(void (EditorNode::*)(EditorNode * const)) 0x55555ade2344 <EditorNode::_fs_changed()>, p_args=0x0, r_error=...) at ./core/variant/binder_common.h:223
    #19 0x000055555ae5be3c in call_with_variant_args<EditorNode> (p_instance=0x555565428880, p_method=(void (EditorNode::*)(EditorNode * const)) 0x55555ade2344 <EditorNode::_fs_changed()>, p_args=0x0, 
        p_argcount=0, r_error=...) at ./core/variant/binder_common.h:337
    #20 0x000055555ae5b117 in CallableCustomMethodPointer<EditorNode, void>::call (this=0x55557709cb00, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...)
        at ./core/object/callable_method_pointer.h:103
    #21 0x000055555e5bd44e in Callable::callp (this=0x7fffffffd310, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...) at core/variant/callable.cpp:57
    #22 0x000055555e9ce463 in Object::emit_signalp (this=0x5555654c67a0, p_name=..., p_args=0x0, p_argcount=0) at core/object/object.cpp:1341
    #23 0x000055555c1929f1 in Node::emit_signalp (this=0x5555654c67a0, p_name=..., p_args=0x0, p_argcount=0) at scene/main/node.cpp:4166
    #24 0x0000555559085fca in Object::emit_signal<>(StringName const&) (this=0x5555654c67a0, p_name=...) at ./core/object/object.h:967
    #25 0x000055555b22120f in EditorFileSystem::_notification (this=0x5555654c67a0, p_what=17) at editor/file_system/editor_file_system.cpp:1795
    #26 0x000055555b233492 in EditorFileSystem::_notification_forwardv (this=0x5555654c67a0, p_notification=17) at editor/file_system/editor_file_system.h:148
    #27 0x000055555e9cc317 in Object::_notification_forward (this=0x5555654c67a0, p_notification=17) at core/object/object.cpp:993
    #28 0x0000555558c929d8 in Object::notification (this=0x5555654c67a0, p_notification=17, p_reversed=false) at ./core/object/object.h:919
    #29 0x000055555c1ca335 in SceneTree::_process_group (this=0x55556542dd40, p_group=0x55556542df60, p_physics=false) at scene/main/scene_tree.cpp:1202
    #30 0x000055555c1ca91e in SceneTree::_process (this=0x55556542dd40, p_physics=false) at scene/main/scene_tree.cpp:1279
    #31 0x000055555c1c83ec in SceneTree::process (this=0x55556542dd40, p_time=0.0068970000000000004) at scene/main/scene_tree.cpp:706
    #32 0x0000555558d852bf in Main::iteration () at main/main.cpp:4748
    #33 0x0000555558c9aa0e in OS_LinuxBSD::run (this=0x7fffffffd850) at platform/linuxbsd/os_linuxbsd.cpp:991
    #34 0x0000555558cb0bf0 in main (argc=5, argv=0x7fffffffde88) at platform/linuxbsd/godot_linuxbsd.cpp:85
    

    some potentially useful variable values:

    (gdb) p this
    $2 = (const godot::AHashMap<godot::StringName, godot::ClassDB::ClassInfo::VirtualMethod, godot::HashMapHasherDefault, godot::HashMapComparatorDefault<godot::StringName> > * const) 0x555564c37158
    (gdb) p *this
    $3 = {static INITIAL_CAPACITY = <optimized out>, static EMPTY_HASH = <optimized out>, elements = 0x555564c33660, map_data = 0x0, capacity = 65, num_elements = 0}
    

    I think it'd be useful to provide the pointer that I as well

    since I use CLion's debugger I can provide a screenshot

    before crash

    Image

    after crash

    Image

    the virtual lookup seems to be called twice when calling the function for the class, because according to the debugger, when the call to _gdvirtual__get_minimum_size_call is dispatched there's 1 invocation that has valid hashmap data (the picture from before the segfault) but then at roughly the same time (or shortly thereafter) it gets called again on the same pointer (in this case it's the ```GraphicsPanel``) and that's the second picture, the hashmap data after it's called again.

    I've went through the scene these erroring classes are a part of using a text editor, there's only 1 instance of these classes, no GDScript attatched to them, and their thread groups have not changed.

    When I add these offending classes to a scene that can still open as these classes don't appear in those scenes, it still crashes outright

    not sure if this is useful, but this is the this pointer of the control that causes the issue

    Image
  14. xana43 commented on Oct 26, 2025

    @xana43
    Author

    EDIT: this solution only seems to work some of the time, but not all of the time. after trying a few more times it broke again after compiling one more time. this might be a result of compiler entropy, but I still think it's interesting that this is breaking virtual functions registered through the bindings

    I just stumbled upon another interesting bit of information while messing around with things. So I fixed the crashing with the options panel, but not with the enemy class.

    previously I had a function that notified the entire tree that an option changed

    emit_singnal(/*emit a signal that an option has changed*/);
    get_tree()->get_root()->propagate_notification(/*emit a notification that an option has changed to the tree so we don't always need a reference to this class*/) 

    this function (only consisting of those two lines) appeared in the header of the base OptionPanel class, as such I needed to include

    #include <godot_cpp/classes/scene_tree.hpp>
    #include <godot_cpp/classes/window.hpp>

    when I moved this function out of the header into a source file I also moved this function into said source file. This fixed all the issues I was having with this specific chain of inheritance. it might be due to scene_tree.hpp or window.hpp also containing the function register_virtuals() and because of how includes work, it was originally like this

    //this is in optionpanel.hpp
    #include <godot_cpp/classes/panel.hpp> //this is for the actual panel class we're inherting from directly
    #include <godot_cpp/classes/scene_tree.hpp>
    #include <godot_cpp/classes/window.hpp>

    however, putting the two headers required for get_tree() into the source file solved this issue. However the problem still remains with the enemy class

  15. xana43 commented on Oct 28, 2025

    @xana43
    Author

    as I final note pending more investigation. The only thing I can conclude now is that it has something to do with the amount of classes registered, I've recreated all the conditions that create the crash in a new project, same version of the compiler, same compiler flags that it compiles with for debug, same everything. the only thing that isn't the same is the amount of classes and abstract classes that are registered with the engine, my main project has about 70 classes in total and 8 abstract classes. I'll get to work on seeing if that's the case, if not then I have no clue

  16. xana43 commented on Nov 4, 2025

    @xana43
    Author

    after tons and tons and tons of tinkering. I initially gave up on this issue and just decided to not worry about testing any code in the godot engine, but then after a few updates to my version of the linux kernel the issue seems to have been fixed. I will continue to monitor how things are going. but it feels like the issue was with the linux kernel, which appears to be fixed now.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcrash

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions