Crashes when running test project
Closed this issue · 5 comments
Running test project https://github.com/qarmin/RegressionTestProject/archive/refs/heads/4.0.zip crashes with this backtraces(I use Godot with address sanitizer)
WorldECS.get_entity_component_by_name
Parameters [100, ]
ERROR: The passed component_name is not valid.
at: has_entity_component (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:516)
/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:502:86: runtime error: member access within null pointer of type 'struct StorageBase'
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /mnt/Miecz/godot/bin/godot.linuxbsd.tools.64s() [0x2045552] (/mnt/Miecz/godot/platform/linuxbsd/crash_handler_linuxbsd.cpp:54)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7f7d6e067210] (??:0)
[3] WorldECS::get_entity_component(unsigned int, unsigned int) (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:502)
[4] WorldECS::get_entity_component_by_name(unsigned int, StringName const&) (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:493 (discriminator 2))
[5] void call_with_variant_args_ret_helper<__UnexistingClass, Object*, unsigned int, StringName const&, 0ul, 1ul>(__UnexistingClass*, Object* (__UnexistingClass::*)(unsigned int, StringName const&), Variant const**, Variant&, Callable::CallError&, IndexSequence<0ul, 1ul>) (/mnt/Miecz/godot/./core/variant/binder_common.h:603 (discriminator 6))
[6] void call_with_variant_args_ret_dv<__UnexistingClass, Object*, unsigned int, StringName const&>(__UnexistingClass*, Object* (__UnexistingClass::*)(unsigned int, StringName const&), Variant const**, int, Variant&, Callable::CallError&, Vector<Variant> const&) (/mnt/Miecz/godot/./core/variant/binder_common.h:389)
[7] MethodBindTR<Object*, unsigned int, StringName const&>::call(Object*, Variant const**, int, Callable::CallError&) (/mnt/Miecz/godot/./core/object/method_bind.h:452)
[8] Object::call(StringName const&, Variant const**, int, Callable::CallError&) (/mnt/Miecz/godot/core/object/object.cpp:784 (discriminator 1))
[9] Object::callv(StringName const&, Array const&) (/mnt/Miecz/godot/core/object/object.cpp:709 (discriminator 1))
[10] void call_with_variant_args_ret_helper<__UnexistingClass, Variant, StringName const&, Array const&, 0ul, 1ul>(__UnexistingClass*, Variant (__UnexistingClass::*)(StringName const&, Array const&), Variant const**, Variant&, Callable::CallError&, IndexSequence<0ul, 1ul>) (/mnt/Miecz/godot/./core/variant/binder_common.h:603 (discriminator 8))
[11] void call_with_variant_args_ret_dv<__UnexistingClass, Variant, StringName const&, Array const&>(__UnexistingClass*, Variant (__UnexistingClass::*)(StringName const&, Array const&), Variant const**, int, Variant&, Callable::CallError&, Vector<Variant> const&) (/mnt/Miecz/godot/./core/variant/binder_common.h:389)
[12] MethodBindTR<Variant, StringName const&, Array const&>::call(Object*, Variant const**, int, Callable::CallError&) (/mnt/Miecz/godot/./core/object/method_bind.h:452)
[13] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/mnt/Miecz/godot/modules/gdscript/gdscript_vm.cpp:1496 (discriminator 1))
[14] GDScriptInstance::call(StringName const&, Variant const**, int, Callable::CallError&) (/mnt/Miecz/godot/./modules/gdscript/gdscript.cpp:1552)
[15] Object::call(StringName const&, Variant const**, int, Callable::CallError&) (/mnt/Miecz/godot/core/object/object.cpp:765 (discriminator 1))
[16] Variant::call(StringName const&, Variant const**, int, Variant&, Callable::CallError&) (/mnt/Miecz/godot/core/variant/variant_call.cpp:713)
[17] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/mnt/Miecz/godot/modules/gdscript/gdscript_vm.cpp:1394)
[18] GDScriptInstance::call(StringName const&, Variant const**, int, Callable::CallError&) (/mnt/Miecz/godot/./modules/gdscript/gdscript.cpp:1552)
[19] ScriptInstance::call(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (/mnt/Miecz/godot/core/object/script_language.cpp:311)
[20] Node::_notification(int) (/mnt/Miecz/godot/scene/main/node.cpp:147)
[21] Node::_notificationv(int, bool) (/mnt/Miecz/godot/./scene/main/node.h:45 (discriminator 14))
[22] Object::notification(int, bool) (/mnt/Miecz/godot/core/object/object.cpp:795)
[23] Node::_propagate_ready() (/mnt/Miecz/godot/scene/main/node.cpp:189)
[24] Node::_propagate_ready() (/mnt/Miecz/godot/scene/main/node.cpp:179 (discriminator 2))
[25] Node::_set_tree(SceneTree*) (/mnt/Miecz/godot/scene/main/node.cpp:2525)
[26] SceneTree::initialize() (/mnt/Miecz/godot/scene/main/scene_tree.cpp:395)
[27] OS_LinuxBSD::run() (/mnt/Miecz/godot/platform/linuxbsd/os_linuxbsd.cpp:256)
[28] /mnt/Miecz/godot/bin/godot.linuxbsd.tools.64s(main+0x3fc) [0x2043032] (/mnt/Miecz/godot/platform/linuxbsd/godot_linuxbsd.cpp:60)
[29] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f7d6e0480b3] (??:0)
[30] /mnt/Miecz/godot/bin/godot.linuxbsd.tools.64s(_start+0x2e) [0x2042b7e] (??:?)
There is also memory leak
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7ff340b29f17 in operator new(unsigned long) (/lib/x86_64-linux-gnu/libasan.so.6+0xb1f17)
#1 0x3ca43d9 in void WorldCommands::add_method<WorldCommands, EntityID>(StringName const&, void (WorldCommands::*)(EntityID)) /mnt/Miecz/modules/godex/world/world.h:59
#2 0x3c9b1b5 in WorldCommands::_bind_methods() /mnt/Miecz/modules/godex/world/world.cpp:23
#3 0x3ce7f0f in void ECS::register_databag<WorldCommands>() /mnt/Miecz/modules/godex/components/../ecs.h:430
#4 0x3cdfb44 in register_godex_types() /mnt/Miecz/modules/godex/register_types.cpp:30
#5 0x2e60ff3 in register_module_types() modules/register_module_types.gen.cpp:483
#6 0x218cf52 in Main::setup2(unsigned long) main/main.cpp:1764
#7 0x218030e in Main::setup(char const*, int, char**, bool) main/main.cpp:1387
#8 0x2042f36 in main platform/linuxbsd/godot_linuxbsd.cpp:51
#9 0x7ff33fc430b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7ff340b29f17 in operator new(unsigned long) (/lib/x86_64-linux-gnu/libasan.so.6+0xb1f17)
#1 0x3ca3d5b in void WorldCommands::add_method<EntityID, WorldCommands>(StringName const&, EntityID (WorldCommands::*)()) /mnt/Miecz/modules/godex/world/world.h:59
#2 0x3c9b10e in WorldCommands::_bind_methods() /mnt/Miecz/modules/godex/world/world.cpp:22
#3 0x3ce7f0f in void ECS::register_databag<WorldCommands>() /mnt/Miecz/modules/godex/components/../ecs.h:430
#4 0x3cdfb44 in register_godex_types() /mnt/Miecz/modules/godex/register_types.cpp:30
#5 0x2e60ff3 in register_module_types() modules/register_module_types.gen.cpp:483
#6 0x218cf52 in Main::setup2(unsigned long) main/main.cpp:1764
#7 0x218030e in Main::setup(char const*, int, char**, bool) main/main.cpp:1387
#8 0x2042f36 in main platform/linuxbsd/godot_linuxbsd.cpp:51
#9 0x7ff33fc430b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
Changed scene to res://ReparentingDeleting/ReparentingDeleting.tscn
DisplayServer::_create_window 3 want rect: 0, 0, 100, 100 got rect 0, 0, 100, 100
ERROR: Only one WorldECS is allowed at a time.
at: active_world (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:441)
ERROR: Condition "!data.grouped.has(p_identifier)" is true.
at: remove_from_group (scene/main/node.cpp:1746)
ERROR: Condition "!data.tree" is true. Returning: nullptr
at: get_tree (./scene/main/node.h:280)
/mnt/Miecz/modules/godex/ecs.cpp:425:42: runtime error: member call on null pointer of type 'struct SceneTree'
/mnt/Miecz/modules/godex/ecs.cpp:425:42: runtime error: member access within null pointer of type 'struct SceneTree'
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /mnt/Miecz/godot/bin/godot.linuxbsd.tools.64s() [0x2045552] (/mnt/Miecz/godot/platform/linuxbsd/crash_handler_linuxbsd.cpp:54)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7f2226302210] (??:0)
[3] ECS::set_active_world(World*, WorldECS*) (/mnt/Miecz/modules/godex/ecs.cpp:425)
[4] WorldECS::active_world() (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:429 (discriminator 1))
[5] WorldECS::_notification(int) (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:294)
[6] WorldECS::_notificationv(int, bool) (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.h:78 (discriminator 14))
[7] Object::notification(int, bool) (/mnt/Miecz/godot/core/object/object.cpp:795)
[8] Node::propagate_notification(int) (/mnt/Miecz/godot/scene/main/node.cpp:1849)
[9] Node::propagate_notification(int) (/mnt/Miecz/godot/scene/main/node.cpp:1849 (discriminator 2))
[10] Node::propagate_notification(int) (/mnt/Miecz/godot/scene/main/node.cpp:1849 (discriminator 2))
[11] Node::propagate_notification(int) (/mnt/Miecz/godot/scene/main/node.cpp:1849 (discriminator 2))
[12] ECS::set_active_world(World*, WorldECS*) (/mnt/Miecz/modules/godex/ecs.cpp:432)
[13] WorldECS::unactive_world() (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:451)
[14] WorldECS::_notification(int) (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.cpp:299)
[15] WorldECS::_notificationv(int, bool) (/mnt/Miecz/modules/godex/modules/godot/nodes/ecs_world.h:78 (discriminator 14))
[16] Object::notification(int, bool) (/mnt/Miecz/godot/core/object/object.cpp:795)
[17] Node::_propagate_exit_tree() (/mnt/Miecz/godot/scene/main/node.cpp:270)
[18] Node::_propagate_exit_tree() (/mnt/Miecz/godot/scene/main/node.cpp:258 (discriminator 2))
[19] Node::_set_tree(SceneTree*) (/mnt/Miecz/godot/scene/main/node.cpp:2514)
[20] Node::remove_child(Node*) (/mnt/Miecz/godot/scene/main/node.cpp:1318)
[21] Node::_notification(int) (/mnt/Miecz/godot/scene/main/node.cpp:166)
[22] Node::_notificationv(int, bool) (/mnt/Miecz/godot/./scene/main/node.h:45 (discriminator 14))
[23] Object::notification(int, bool) (/mnt/Miecz/godot/core/object/object.cpp:795)
[24] Object::_predelete() (/mnt/Miecz/godot/core/object/object.cpp:355)
[25] predelete_handler(Object*) (/mnt/Miecz/godot/core/object/object.cpp:1815)
[26] void memdelete<Object>(Object*) (/mnt/Miecz/godot/./core/os/memory.h:111)
[27] SceneTree::_flush_delete_queue() (/mnt/Miecz/godot/scene/main/scene_tree.cpp:996)
[28] SceneTree::process(float) (/mnt/Miecz/godot/scene/main/scene_tree.cpp:456 (discriminator 5))
[29] Main::iteration() (/mnt/Miecz/godot/main/main.cpp:2505 (discriminator 2))
[30] OS_LinuxBSD::run() (/mnt/Miecz/godot/platform/linuxbsd/os_linuxbsd.cpp:261)
[31] /mnt/Miecz/godot/bin/godot.linuxbsd.tools.64s(main+0x3fc) [0x2043032] (/mnt/Miecz/godot/platform/linuxbsd/godot_linuxbsd.cpp:60)
[32] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f22262e30b3] (??:0)
[33] /mnt/Miecz/godot/bin/godot.linuxbsd.tools.64s(_start+0x2e) [0x2042b7e] (??:?)
Nice, thanks for the issue, I'll investigate this in the coming days.
Can you try it again with the last build please? I did some changes and also submitted this #140. It fixes a crash that I found thanks to this regression test.
I can't reproduce your issue. Now it crashes elsewhere, but it seems caused by something else.
For now this code crashes(this may not 100% accurate since I used normal build without debug symbols and sanitizers)
WorldECS.new().get_entity_component(48, -20)
ClassDB.instantiate("DynamicQuery").get_component(-2)
WorldECS.new().get_entity_component_by_name(18, StringName("4241818282"))
Entity2D.new().add_component(StringName("."), {})
Interesting, those are not supposed to be used in that way. Though, they should not crash, thanks for the report!
I've fixed those with this one: #215
The following code doesn't crash anymore:
WorldECS.new().get_entity_component(48, -20)
ClassDB.instantiate("DynamicQuery").get_component(2)
ClassDB.instantiate("DynamicQuery").get_component(-2)
ClassDB.instantiate("DynamicQuery").count()
ClassDB.instantiate("DynamicQuery").has(-30)
ClassDB.instantiate("DynamicQuery").fetch(-30)
ClassDB.instantiate("DynamicQuery").begin(null)
ClassDB.instantiate("DynamicQuery").end()
DynamicQuery.new().get_component(-2)
DynamicQuery.new().reset()
DynamicQuery.new().get_current_entity_id()
WorldECS.new().get_entity_component_by_name(18, StringName("4241818282"))
Entity2D.new().add_component(StringName("."), {})
Thanks for the heads up!!