godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91k stars 21.17k forks source link

Editor crash when closing scene with Joint3D #60962

Closed LD2Studio closed 2 years ago

LD2Studio commented 2 years ago

Godot version

v4.0.alpha7.official

System information

Kubuntu 20.04, Intel i5-2500, 16Go, NVIDIA GTX1650

Issue description

If a scene contains a Joint3D node (PinJoint3D, HingeJoint3D, ...), this scene cannot be closed from the editor without crashing the Godot engine.

Steps to reproduce

Create a scene with Node3D root. Add a PinJoint3D node into this scene. Now if we close the scene by clicking on the cross of the tab, the Godot engine crashes. img1

img2

Minimal reproduction project

IssueCrashCloseScene.zip

Chaosus commented 2 years ago

I cannot reproduce this crash on Windows11, only some error spamming to console: bug

LD2Studio commented 2 years ago

This bug happen only on Linux, not on Windows (i had tested)

timothyqiu commented 2 years ago

Seems fixed on master. I can reproduce this on Arch Linux with alpha7, but not current master.

akien-mga commented 2 years ago

It's still reproducible in 4.0 alpha 8 for me on Linux, using official builds. It might be specific to release_debug builds and not reproducible in debug.

akien-mga commented 2 years ago

Actually it crashes in target=debug build too, in latest master (edda6ee9f82ec94f993ebf44486ab7d8abcef193):

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.alpha.custom_build (edda6ee9f82ec94f993ebf44486ab7d8abcef193)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib64/libc.so.6(+0x3c3a0) [0x7fd9bf3a33a0] (??:0)
[2] /home/akien/Projects/godot/godot.git/bin/godot.linuxbsd.tools.64(__dynamic_cast+0x3f) [0x69fca2f] (/home/iurt/rpmbuild/BUILD/gcc-12-20220507/obj-x86_64-mageia-linux/x86_64-mageia-linux/libstdc++-v3/libsupc++/../../../../libstdc++-v3/libsupc++/dyncast.cc:71)
[3] Node* Object::cast_to<Node>(Object*) (/home/akien/Projects/godot/godot.git/./core/object/object.h:641 (discriminator 1))
[4] VariantObjectClassChecker<Node*>::check(Variant const&) (/home/akien/Projects/godot/godot.git/./core/variant/binder_common.h:163)
[5] VariantCasterAndValidate<Node*>::cast(Variant const**, unsigned int, Callable::CallError&) (/home/akien/Projects/godot/godot.git/./core/variant/binder_common.h:189 (discriminator 2))
[6] void call_with_variant_args_helper<SceneTreeEditor, Node*, 0ul>(SceneTreeEditor*, void (SceneTreeEditor::*)(Node*), Variant const**, Callable::CallError&, IndexSequence<0ul>) (/home/akien/Projects/godot/godot.git/./core/variant/binder_common.h:236 (discriminator 4))
[7] void call_with_variant_args<SceneTreeEditor, Node*>(SceneTreeEditor*, void (SceneTreeEditor::*)(Node*), Variant const**, int, Callable::CallError&) (/home/akien/Projects/godot/godot.git/./core/variant/binder_common.h:351)
[8] CallableCustomMethodPointer<SceneTreeEditor, Node*>::call(Variant const**, int, Variant&, Callable::CallError&) const (/home/akien/Projects/godot/godot.git/./core/object/callable_method_pointer.h:105)
[9] Callable::call(Variant const**, int, Variant&, Callable::CallError&) const (/home/akien/Projects/godot/godot.git/core/variant/callable.cpp:64)
[10] MessageQueue::_call_function(Callable const&, Variant const*, int, bool) (/home/akien/Projects/godot/godot.git/core/object/message_queue.cpp:230)
[11] MessageQueue::flush() (/home/akien/Projects/godot/godot.git/core/object/message_queue.cpp:277)
[12] SceneTree::physics_process(double) (/home/akien/Projects/godot/godot.git/scene/main/scene_tree.cpp:421)
[13] Main::iteration() (/home/akien/Projects/godot/godot.git/main/main.cpp:2715)
[14] OS_LinuxBSD::run() (/home/akien/Projects/godot/godot.git/platform/linuxbsd/os_linuxbsd.cpp:441)
[15] /home/akien/Projects/godot/godot.git/bin/godot.linuxbsd.tools.64(main+0x136) [0x2231f5c] (/home/akien/Projects/godot/godot.git/platform/linuxbsd/godot_linuxbsd.cpp:70)
[16] /lib64/libc.so.6(+0x29177) [0x7fd9bf390177] (??:0)
[17] /lib64/libc.so.6(__libc_start_main+0x85) [0x7fd9bf390235] (??:0)
[18] /home/akien/Projects/godot/godot.git/bin/godot.linuxbsd.tools.64(_start+0x21) [0x2231d61] (??:?)
-- END OF BACKTRACE --
================================================================
akien-mga commented 2 years ago

Did some testing, the bug is reproducible all the way down to 4.0 alpha 1.

In earlier testing builds, it seems the bug was introduced between https://downloads.tuxfamily.org/godotengine/testing/4.0/4.0-dev.20211210/ (21b81998bb42b2324a539f01354b68e4fba2c696) and https://downloads.tuxfamily.org/godotengine/testing/4.0/4.0-dev.20220105/ (8f6cba3a44aa9daa8a2694abf2d2647b03b60dc8). https://github.com/godotengine/godot/compare/21b81998bb42b2324a539f01354b68e4fba2c696...8f6cba3a44aa9daa8a2694abf2d2647b03b60dc8

qarmin commented 2 years ago

Crash is caused by using freed memory, so this explain why not always crash happens for everyone

Invalid read of size 8
   at 0x712AC41: __dynamic_cast (in /usr/bin/godot4)
   by 0x241A876: Node* Object::cast_to<Node>(Object*) (object.h:642)
   by 0x2B42C63: VariantObjectClassChecker<Node*>::check(Variant const&) (binder_common.h:163)
   by 0x2B4289E: VariantCasterAndValidate<Node*>::cast(Variant const**, unsigned int, Callable::CallError&) (binder_common.h:189)
   by 0x403FAFD: void call_with_variant_args_helper<SceneTreeEditor, Node*, 0ul>(SceneTreeEditor*, void (SceneTreeEditor::*)(Node*), Variant const**, Callable::CallError&, IndexSequence<0ul>) (binder_common.h:236)
   by 0x403F31D: void call_with_variant_args<SceneTreeEditor, Node*>(SceneTreeEditor*, void (SceneTreeEditor::*)(Node*), Variant const**, int, Callable::CallError&) (binder_common.h:350)
   by 0x403EA0F: CallableCustomMethodPointer<SceneTreeEditor, Node*>::call(Variant const**, int, Variant&, Callable::CallError&) const (callable_method_pointer.h:104)
   by 0x69BC4A2: Callable::call(Variant const**, int, Variant&, Callable::CallError&) const (callable.cpp:50)
   by 0x6CA4778: MessageQueue::_call_function(Callable const&, Variant const*, int, bool) (message_queue.cpp:229)
   by 0x6CA4AD9: MessageQueue::flush() (message_queue.cpp:275)
   by 0x4CFF03F: SceneTree::physics_process(double) (scene_tree.cpp:419)
   by 0x2415A90: Main::iteration() (main.cpp:2715)
   by 0x23C8873: OS_LinuxBSD::run() (os_linuxbsd.cpp:441)
   by 0x23C3AB1: main (godot_linuxbsd.cpp:68)
 Address 0x44112050 is 16 bytes inside a block of size 1,152 free'd
   at 0xB20792F: free (vg_replace_malloc.c:872)
   by 0x6771EA2: Memory::free_static(void*, bool) (memory.cpp:168)
   by 0x2B1EC29: void memdelete<Node>(Node*) (memory.h:111)
   by 0x4CC165D: Node::_notification(int) (node.cpp:169)
   by 0x27C10F7: Node::_notificationv(int, bool) (node.h:45)
   by 0x27C19A4: Node3D::_notificationv(int, bool) (node_3d.h:52)
   by 0x6CAC38A: Object::notification(int, bool) (object.cpp:847)
   by 0x6CA9D58: Object::_predelete() (object.cpp:354)
   by 0x6CB6B7A: predelete_handler(Object*) (object.cpp:1913)
   by 0x2B1EBF8: void memdelete<Node>(Node*) (memory.h:104)
   by 0x3B80A2F: EditorData::remove_scene(int) (editor_data.cpp:536)
   by 0x3CDBFC5: EditorNode::_remove_edited_scene(bool) (editor_node.cpp:3401)
   by 0x3CDC057: EditorNode::_remove_scene(int, bool) (editor_node.cpp:3413)
   by 0x3CD822F: EditorNode::_discard_changes(String const&) (editor_node.cpp:3086)
   by 0x3CEBB2D: EditorNode::_scene_tab_closed(int, int) (editor_node.cpp:5069)
   by 0x3D49C55: void call_with_variant_args_helper<EditorNode, int, int, 0ul, 1ul>(EditorNode*, void (EditorNode::*)(int, int), Variant const**, Callable::CallError&, IndexSequence<0ul, 1ul>) (binder_common.h:236)
   by 0x3D48201: void call_with_variant_args<EditorNode, int, int>(EditorNode*, void (EditorNode::*)(int, int), Variant const**, int, Callable::CallError&) (binder_common.h:350)
   by 0x3D4446B: CallableCustomMethodPointer<EditorNode, int, int>::call(Variant const**, int, Variant&, Callable::CallError&) const (callable_method_pointer.h:104)
   by 0x69BC4A2: Callable::call(Variant const**, int, Variant&, Callable::CallError&) const (callable.cpp:50)
   by 0x6CAE2AE: Object::emit_signalp(StringName const&, Variant const**, int) (object.cpp:1119)
   by 0x289FA60: Error Object::emit_signal<int>(StringName const&, int) (object.h:774)
   by 0x50312E8: TabBar::gui_input(Ref<InputEvent> const&) (tab_bar.cpp:206)
   by 0x4E4C4A3: Control::_call_gui_input(Ref<InputEvent> const&) (control.cpp:941)
   by 0x4D2DA5B: Viewport::_gui_call_input(Control*, Ref<InputEvent> const&) (viewport.cpp:1301)
   by 0x4D2EEFE: Viewport::_gui_input_event(Ref<InputEvent>) (viewport.cpp:1604)
   by 0x4D35D83: Viewport::push_input(Ref<InputEvent> const&, bool) (viewport.cpp:2718)
   by 0x4D79ADF: Window::_window_input(Ref<InputEvent> const&) (window.cpp:973)
   by 0x4D9A329: void call_with_variant_args_helper<Window, Ref<InputEvent> const&, 0ul>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, Callable::CallError&, IndexSequence<0ul>) (binder_common.h:236)
   by 0x4D9721C: void call_with_variant_args<Window, Ref<InputEvent> const&>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, int, Callable::CallError&) (binder_common.h:350)
   by 0x4D93597: CallableCustomMethodPointer<Window, Ref<InputEvent> const&>::call(Variant const**, int, Variant&, Callable::CallError&) const (callable_method_pointer.h:104)
   by 0x69BC4A2: Callable::call(Variant const**, int, Variant&, Callable::CallError&) const (callable.cpp:50)
   by 0x23E29E9: DisplayServerX11::_dispatch_input_event(Ref<InputEvent> const&) (display_server_x11.cpp:3136)
   by 0x23E274C: DisplayServerX11::_dispatch_input_events(Ref<InputEvent> const&) (display_server_x11.cpp:3107)
   by 0x695BB39: Input::_parse_input_event_impl(Ref<InputEvent> const&, bool) (input.cpp:658)
   by 0x695D13A: Input::flush_buffered_events() (input.cpp:883)
   by 0x23E7469: DisplayServerX11::process_events() (display_server_x11.cpp:4110)
   by 0x23C885B: OS_LinuxBSD::run() (os_linuxbsd.cpp:437)
   by 0x23C3AB1: main (godot_linuxbsd.cpp:68)
 Block was alloc'd at
   at 0xB205045: malloc (vg_replace_malloc.c:381)
   by 0x67717E8: Memory::alloc_static(unsigned long, bool) (memory.cpp:75)
   by 0x6771768: operator new(unsigned long, char const*) (memory.cpp:40)
   by 0x4C67C9F: Object* ClassDB::creator<PinJoint3D>() (class_db.h:133)
   by 0x6C8F847: ClassDB::instantiate(StringName const&) (class_db.cpp:350)
   by 0x5872CA1: SceneState::instantiate(SceneState::GenEditState) const (packed_scene.cpp:181)
   by 0x587F966: PackedScene::instantiate(PackedScene::GenEditState) const (packed_scene.cpp:1674)
   by 0x3CDE27C: EditorNode::load_scene(String const&, bool, bool, bool, bool, bool) (editor_node.cpp:3704)
   by 0x3CDEBDC: EditorNode::open_request(String const&) (editor_node.cpp:3764)
   by 0x3EE809F: FileSystemDock::_select_file(String const&, bool) (filesystem_dock.cpp:1005)
   by 0x3EE8753: FileSystemDock::_tree_activate_file() (filesystem_dock.cpp:1045)
   by 0x3F18523: void call_with_variant_args_helper<FileSystemDock>(FileSystemDock*, void (FileSystemDock::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (binder_common.h:236)
   by 0x3F17761: void call_with_variant_args<FileSystemDock>(FileSystemDock*, void (FileSystemDock::*)(), Variant const**, int, Callable::CallError&) (binder_common.h:350)
   by 0x3F16A0F: CallableCustomMethodPointer<FileSystemDock>::call(Variant const**, int, Variant&, Callable::CallError&) const (callable_method_pointer.h:104)
   by 0x69BC4A2: Callable::call(Variant const**, int, Variant&, Callable::CallError&) const (callable.cpp:50)
   by 0x6CAE2AE: Object::emit_signalp(StringName const&, Variant const**, int) (object.cpp:1119)
   by 0x2897126: Error Object::emit_signal<>(StringName const&) (object.h:774)
   by 0x50EEC97: Tree::gui_input(Ref<InputEvent> const&) (tree.cpp:3453)
   by 0x4E4C4A3: Control::_call_gui_input(Ref<InputEvent> const&) (control.cpp:941)
   by 0x4D2DA5B: Viewport::_gui_call_input(Control*, Ref<InputEvent> const&) (viewport.cpp:1301)
   by 0x4D2EA1A: Viewport::_gui_input_event(Ref<InputEvent>) (viewport.cpp:1534)
   by 0x4D35D83: Viewport::push_input(Ref<InputEvent> const&, bool) (viewport.cpp:2718)
   by 0x4D79ADF: Window::_window_input(Ref<InputEvent> const&) (window.cpp:973)
   by 0x4D9A329: void call_with_variant_args_helper<Window, Ref<InputEvent> const&, 0ul>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, Callable::CallError&, IndexSequence<0ul>) (binder_common.h:236)
   by 0x4D9721C: void call_with_variant_args<Window, Ref<InputEvent> const&>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, int, Callable::CallError&) (binder_common.h:350)
   by 0x4D93597: CallableCustomMethodPointer<Window, Ref<InputEvent> const&>::call(Variant const**, int, Variant&, Callable::CallError&) const (callable_method_pointer.h:104)
   by 0x69BC4A2: Callable::call(Variant const**, int, Variant&, Callable::CallError&) const (callable.cpp:50)
   by 0x23E29E9: DisplayServerX11::_dispatch_input_event(Ref<InputEvent> const&) (display_server_x11.cpp:3136)
   by 0x23E274C: DisplayServerX11::_dispatch_input_events(Ref<InputEvent> const&) (display_server_x11.cpp:3107)
   by 0x695BB39: Input::_parse_input_event_impl(Ref<InputEvent> const&, bool) (input.cpp:658)
   by 0x695D13A: Input::flush_buffered_events() (input.cpp:883)
   by 0x23E7469: DisplayServerX11::process_events() (display_server_x11.cpp:4110)
   by 0x23C885B: OS_LinuxBSD::run() (os_linuxbsd.cpp:437)
   by 0x23C3AB1: main (godot_linuxbsd.cpp:68)