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

Shape2D and Shape3D RID allocations can leak since #67714 #68973

Closed
adamscott opened this issue Nov 21, 2022 · 3 comments · Fixed by #69506
Closed

Shape2D and Shape3D RID allocations can leak since #67714 #68973

adamscott opened this issue Nov 21, 2022 · 3 comments · Fixed by #69506

Comments

@adamscott
Copy link
Member

adamscott commented Nov 21, 2022

Godot version

4.0.dev (11e1c83)

System information

Linux (Ubuntu 22.04), Vulkan, Radeon RX Vega 64 (eGPU)

Issue description

Since the merge of #67714, some RID allocations of Shape2D and Shape3D can leak when the PhysicsServer singleton is disposed before the GDScript holding them.

This was a known issue when the merge occured.

ERROR: 3450 RID allocations of type 'P12GodotShape2D' were leaked at exit.

Steps to reproduce

Investigating now.

Minimal reproduction project

Not yet.

@qarmin
Copy link
Contributor

qarmin commented Nov 22, 2022

 extends Node
func _process(delta):


	var temp_variable_f3088366 = RID()
	var temp_variable_f3088367 = null
	var temp_variable_f3088368 = StringName("")
	var temp_variable_f3088369 = {"roman" : 22, 22 : 25, BoxShape3D.new() : BoxShape3D.new()}
	NavigationServer3D.agent_set_callback(temp_variable_f3088366,temp_variable_f3088367,temp_variable_f3088368,temp_variable_f3088369)
Direct leak of 272 byte(s) in 2 object(s) allocated from:
    #0 0x7f72a28cd867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x55c7f7032fff in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x55c7f7032f10 in operator new(unsigned long, char const*) core/os/memory.cpp:40
    #3 0x55c7f3a21867 in GodotPhysicsServer3D::box_shape_create() servers/physics_3d/godot_physics_server_3d.cpp:66
    #4 0x55c7f5cceac4 in PhysicsServer3DWrapMT::box_shape_create() servers/physics_server_3d_wrap_mt.h:82
    #5 0x55c7f30b43d2 in PhysicsServer3D::shape_create(PhysicsServer3D::ShapeType) servers/physics_server_3d.cpp:664
    #6 0x55c7f0d9f62c in BoxShape3D::BoxShape3D() scene/resources/box_shape_3d.cpp:98
    #7 0x55c7ed28c52a in Object* ClassDB::creator<BoxShape3D>() core/object/class_db.h:140
    #8 0x55c7f87a46d3 in ClassDB::instantiate(StringName const&) core/object/class_db.cpp:339
    #9 0x55c7dfae4f59 in GDScriptNativeClass::instantiate() modules/gdscript/gdscript.cpp:92
    #10 0x55c7dfae4911 in GDScriptNativeClass::_new() modules/gdscript/gdscript.cpp:80
    #11 0x55c7dfc4c949 in void call_with_variant_args_ret_helper<__UnexistingClass, Variant>(__UnexistingClass*, Variant (__UnexistingClass::*)(), Variant const**, Variant&, Callable::CallError&, IndexSequence<>) core/variant/binder_common.h:680
    #12 0x55c7dfc4b9da in void call_with_variant_args_ret_dv<__UnexistingClass, Variant>(__UnexistingClass*, Variant (__UnexistingClass::*)(), Variant const**, int, Variant&, Callable::CallError&, Vector<Variant> const&) core/variant/binder_common.h:493
    #13 0x55c7dfc4a569 in MethodBindTR<Variant>::call(Object*, Variant const**, int, Callable::CallError&) core/object/method_bind.h:465
    #14 0x55c7e01723bf in GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) modules/gdscript/gdscript_vm.cpp:1644
    #15 0x55c7dfb2b238 in GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) modules/gdscript/gdscript.cpp:1827
    #16 0x55c7ed59a9b0 in bool Node::_gdvirtual__process_call<false>(double) scene/main/node.h:238
    #17 0x55c7ed50135e in Node::_notification(int) scene/main/node.cpp:56
    #18 0x55c7de67a0df in Node::_notificationv(int, bool) scene/main/node.h:45
    #19 0x55c7f883fbca in Object::notification(int, bool) core/object/object.cpp:790
    #20 0x55c7ed661651 in SceneTree::_notify_group_pause(StringName const&, int) scene/main/scene_tree.cpp:871
    #21 0x55c7ed653cd3 in SceneTree::process(double) scene/main/scene_tree.cpp:469
    #22 0x55c7ddf1d060 in Main::iteration() main/main.cpp:3171
    #23 0x55c7ddd47f85 in OS_LinuxBSD::run() platform/linuxbsd/os_linuxbsd.cpp:799
    #24 0x55c7ddd23d07 in main platform/linuxbsd/godot_linuxbsd.cpp:73
    #25 0x7f72a1d68d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)

@adamscott
Copy link
Member Author

@qarmin Can you upload your minimal reproduction project? I wasn't able to recreate one from scratch yet.

@qarmin
Copy link
Contributor

qarmin commented Dec 8, 2022

Finally found minimal project - #69750
Still happens after merging #69506, the only difference is that at the end

ERROR: Parameter "PhysicsServer3D::get_singleton()" is null.
   at: ~Shape3D (scene/resources/shape_3d.cpp:131)
ERROR: Parameter "PhysicsServer3D::get_singleton()" is null.
   at: ~Shape3D (scene/resources/shape_3d.cpp:131)

is printed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
3 participants