godotengine / godot

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

Godot 4 beta 8 crashes on project launch #69827

Closed Mikeysax closed 1 year ago

Mikeysax commented 1 year ago

Godot version

4.0beta8

System information

PopOS 22.04, 6.0.6-76060006-generic kernel, Ryzen 6800h, Radeon 6700m, amdgpu, Vulkan

Issue description

Attempting to launch a few projects with godot 4 beta 8 results in an immediate crash. Previous beta releases were not an issue:

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.beta8.official (45cac42c0b511672240c1fcccecfd3cc0580edcb)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f42bf042520] (??:0)
[2] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0x4af0600] (??:0)
[3] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0x2268521] (??:0)
[4] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0x1c854c9] (??:0)
[5] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0x434c128] (??:0)
[6] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0x41c8d84] (??:0)
[7] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0x492b535] (??:0)
[8] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0x43e18f7] (??:0)
[9] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0x2a21aa5] (??:0)
[10] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0xe6d865] (??:0)
[11] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0xd9f143] (??:0)
[12] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f42bf029d90] (??:0)
[13] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f42bf029e40] (??:0)
[14] /home/mikeysax/Documents/Code/Godot_v4.0-beta8_linux.x86_64() [0xdc095e] (??:0)
-- END OF BACKTRACE --
================================================================

Steps to reproduce

Launch a project from a previous beta

Minimal reproduction project

n/a

Calinou commented 1 year ago

Can you reproduce this when creating an empty project? If not, please upload a minimal reproduction project to make this easier to troubleshoot.

In any case, if you can compile the engine from source, you could look into bisecting the regression to greatly speed up troubleshooting.

Mikeysax commented 1 year ago

@Calinou I ended up running bisect and this is where it no longer opens the project. It's the good right before the bad:

➜  godot git:(04cd36612a) git bisect good
Bisecting: 36 revisions left to test after this (roughly 5 steps)
[0a3f66471ed79d9b1852150cb059f20f841d46d9] Merge pull request #69712 from bruvzg/real_size
➜  godot git:(0a3f66471e) scons platform="x11" -j4          
scons: Reading SConscript files ...

...

➜  godot git:(0a3f66471e) git bisect bad                    
Bisecting: 17 revisions left to test after this (roughly 4 steps)
[f9bd2ace0bc8839c5c0c6524ba578122b8bbfb34] Merge pull request #68682 from timothyqiu/camera-gizmo-size

I'm gonna keep running bisect; it just takes a while to compile

I'm able to create a new project with the beta 8 binary as well but I'm seeing the following errors when the new project launches:

-- Debug adapter server started ---
--- GDScript language server started ---
  Can't open dynamic library: /home/mikeysax/Documents/Code/godot/modules/text_server_adv/gdextension_build/bin/libtextserver_advanced.linux.template_debug.x86_64.so. Error: /home/mikeysax/Documents/Code/../lib/libtextserver_advanced.linux.template_debug.x86_64.so: cannot open shared object file: No such file or directory
  core/extension/native_extension.cpp:400 - GDExtension dynamic library not found: /home/mikeysax/Documents/Code/godot/modules/text_server_adv/gdextension_build/bin/libtextserver_advanced.linux.template_debug.x86_64.so
  Failed loading resource: res://Documents/Code/godot/modules/text_server_adv/gdextension_build/text_server_adv.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
  Can't open dynamic library: /home/mikeysax/Documents/Code/godot/modules/text_server_fb/gdextension_build/bin/libtextserver_fallback.linux.template_debug.x86_64.so. Error: /home/mikeysax/Documents/Code/../lib/libtextserver_fallback.linux.template_debug.x86_64.so: cannot open shared object file: No such file or directory
  core/extension/native_extension.cpp:400 - GDExtension dynamic library not found: /home/mikeysax/Documents/Code/godot/modules/text_server_fb/gdextension_build/bin/libtextserver_fallback.linux.template_debug.x86_64.so
  Failed loading resource: res://Documents/Code/godot/modules/text_server_fb/gdextension_build/text_server_fb.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
  Transient parent has another exclusive child.
  Can't open dynamic library: /home/mikeysax/Documents/Code/godot/modules/text_server_adv/gdextension_build/bin/libtextserver_advanced.linux.template_debug.x86_64.so. Error: /home/mikeysax/Documents/Code/../lib/libtextserver_advanced.linux.template_debug.x86_64.so: cannot open shared object file: No such file or directory
  core/extension/native_extension.cpp:400 - GDExtension dynamic library not found: /home/mikeysax/Documents/Code/godot/modules/text_server_adv/gdextension_build/bin/libtextserver_advanced.linux.template_debug.x86_64.so
  Failed loading resource: res://Documents/Code/godot/modules/text_server_adv/gdextension_build/text_server_adv.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
  Can't open dynamic library: /home/mikeysax/Documents/Code/godot/modules/text_server_fb/gdextension_build/bin/libtextserver_fallback.linux.template_debug.x86_64.so. Error: /home/mikeysax/Documents/Code/../lib/libtextserver_fallback.linux.template_debug.x86_64.so: cannot open shared object file: No such file or directory
  core/extension/native_extension.cpp:400 - GDExtension dynamic library not found: /home/mikeysax/Documents/Code/godot/modules/text_server_fb/gdextension_build/bin/libtextserver_fallback.linux.template_debug.x86_64.so
  Failed loading resource: res://Documents/Code/godot/modules/text_server_fb/gdextension_build/text_server_fb.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
Mikeysax commented 1 year ago

@Calinou here is the final result of the bisect:

f9bd2ace0bc8839c5c0c6524ba578122b8bbfb34 is the first bad commit
commit f9bd2ace0bc8839c5c0c6524ba578122b8bbfb34
Merge: de6994aa95 6c5dc78f59
Author: Rémi Verschelde <rverschelde@gmail.com>
Date:   Wed Dec 7 13:25:35 2022 +0100

    Merge pull request #68682 from timothyqiu/camera-gizmo-size

    Make Camera3D gizmo the same aspect ratio as its viewport

 editor/plugins/node_3d_editor_gizmos.cpp | 68 ++++++++++++++++++++++----------
 editor/plugins/node_3d_editor_gizmos.h   |  3 ++
 editor/plugins/node_3d_editor_plugin.cpp |  2 +
 scene/3d/camera_3d.cpp                   | 11 ++++++
 4 files changed, 64 insertions(+), 20 deletions(-)

This is the bisect history:

➜  godot git:(04cd36612a) git bisect good
Bisecting: 36 revisions left to test after this (roughly 5 steps)
[0a3f66471ed79d9b1852150cb059f20f841d46d9] Merge pull request #69712 from bruvzg/real_size

...

➜  godot git:(0a3f66471e) git bisect bad                    
Bisecting: 17 revisions left to test after this (roughly 4 steps)
[f9bd2ace0bc8839c5c0c6524ba578122b8bbfb34] Merge pull request #68682 from timothyqiu/camera-gizmo-size

...

➜  godot git:(f9bd2ace0b) ✗ git bisect bad
Bisecting: 9 revisions left to test after this (roughly 3 steps)
[5c635e8f24f052b85abd1aed2ded2e4f738d6b83] Merge pull request #69699 from aaronfranke/fix-variant-sname-inv

...

➜  godot git:(5c635e8f24) ✗ git bisect good                   
Bisecting: 5 revisions left to test after this (roughly 2 steps)
[b3c7822fad0fe0fa1b75721603c8e3f268b88fa4] Merge pull request #69638 from bruvzg/macos_notarytool

...

➜  godot git:(b3c7822fad) ✗ git bisect good                   
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[4b21e656c9d465d4473006d146bd333beba5a6eb] Merge pull request #69702 from bruvzg/menu_safe_rect

...

➜  godot git:(4b21e656c9) ✗ git bisect good                   
Bisecting: 1 revision left to test after this (roughly 1 step)
[de6994aa95a8552a4d6772ce44145d52bf020915] Merge pull request #69674 from rburing/conStraint

...

➜  godot git:(de6994aa95) ✗ git bisect good
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[6c5dc78f59c78657525cd2301a7e945a30835888] Make Camera3D gizmo the same aspect ratio as its viewport

...

➜  godot git:(6c5dc78f59) ✗ git bisect good
f9bd2ace0bc8839c5c0c6524ba578122b8bbfb34 is the first bad commit
commit f9bd2ace0bc8839c5c0c6524ba578122b8bbfb34
Merge: de6994aa95 6c5dc78f59
Author: Rémi Verschelde <rverschelde@gmail.com>
Date:   Wed Dec 7 13:25:35 2022 +0100

    Merge pull request #68682 from timothyqiu/camera-gizmo-size

    Make Camera3D gizmo the same aspect ratio as its viewport

 editor/plugins/node_3d_editor_gizmos.cpp | 68 ++++++++++++++++++++++----------
 editor/plugins/node_3d_editor_gizmos.h   |  3 ++
 editor/plugins/node_3d_editor_plugin.cpp |  2 +
 scene/3d/camera_3d.cpp                   | 11 ++++++
 4 files changed, 64 insertions(+), 20 deletions(-)
Calinou commented 1 year ago

f9bd2ace0bc8839c5c0c6524ba578122b8bbfb34 is https://github.com/godotengine/godot/pull/68682.

One of my guesses is that https://github.com/godotengine/godot/pull/68682/files#diff-98dac9baccb5b2d0bddefafae501beb5f2145c6debfc4023594e0163a1f1316bR1736-R1752 is missing a null check somewhere.

@Mikeysax Can you try to compile a debug build (debug_symbols=yes SCons option) then run it as usual until it crashes?

cc @timothyqiu

Mikeysax commented 1 year ago

@Calinou here is a build with the debug_symbols option which crashes immediately when opening a project:

➜  godot git:(master) ./bin/godot.linuxbsd.editor.x86_64
Godot Engine v4.0.beta.custom_build.ae86d907e - https://godotengine.org
OpenGL Renderer: REMBRANDT (rembrandt, LLVM 14.0.0, DRM 3.48, 6.0.6-76060006-generic)

Editing project: /home/mikeysax/Documents/Code/maskless
Godot Engine v4.0.beta.custom_build.ae86d907e - https://godotengine.org
Vulkan API 1.3.224 - Using Vulkan Device #1: AMD - AMD Radeon RX 6700M (RADV NAVI22)

➜  godot git:(master) WARNING: FBX file import is enabled in the project settings, but no FBX2glTF path is configured in the editor settings. FBX files will not be imported.
     at: _editor_init (modules/gltf/register_types.cpp:99)
ERROR: Condition "!tile_set.is_valid()" is true.
   at: _update_sources_list (editor/plugins/tiles/tile_set_editor.cpp:123)
ERROR: Condition "!tile_set.is_valid()" is true.
   at: _update_sources_list (editor/plugins/tiles/tile_set_editor.cpp:123)
ERROR: Parser bug (please report): tried to assign unset node without an identifier.
   at: resolve_class_interface (modules/gdscript/gdscript_analyzer.cpp:670)
ERROR: Parser bug (please report): Trying to check compatibility of unset value type
   at: is_type_compatible (modules/gdscript/gdscript_analyzer.cpp:4153)
ERROR: Parser bug (please report): tried to assign unset node without an identifier.
   at: resolve_class_interface (modules/gdscript/gdscript_analyzer.cpp:670)
ERROR: Parser bug (please report): Trying to check compatibility of unset value type
   at: is_type_compatible (modules/gdscript/gdscript_analyzer.cpp:4153)
SCRIPT ERROR: Parse Error: Preload file "res://src/gridmaps/test_floor/test.tscn" does not exist.
          at: GDScript::reload (res://src/scenes/levels/test/test.gd:22)
SCRIPT ERROR: Parse Error: Preload file "res://src/scenes/player.player.tscn" does not exist.
          at: GDScript::reload (res://src/scenes/levels/test/test.gd:25)
SCRIPT ERROR: Parse Error: "Player" was not found in the current scope.
          at: GDScript::reload (res://src/scenes/levels/test/test.gd:30)
SCRIPT ERROR: Parse Error: Could not parse global class "ProceduralLevel" from "res://src/procedurals/level.gd".
          at: GDScript::reload (res://src/scenes/levels/test/test.gd:31)
SCRIPT ERROR: Parse Error: Could not parse global class "MeshPlacer" from "res://src/procedurals/mesh_placer.gd".
          at: GDScript::reload (res://src/scenes/levels/test/test.gd:32)
SCRIPT ERROR: Parse Error: Could not find script for class "ProceduralLevel".
          at: GDScript::reload (res://src/scenes/levels/test/test.gd:45)
SCRIPT ERROR: Parse Error: Could not find script for class "MeshPlacer".
          at: GDScript::reload (res://src/scenes/levels/test/test.gd:46)
ERROR: Attempt to disconnect a nonexistent connection from 'Skeleton3D:<Skeleton3D#1772160609762>'. Signal: 'bone_pose_changed', callable: 'BoneAttachment3D::on_bone_pose_update'.
   at: _disconnect (core/object/object.cpp:1327)
ERROR: Attempt to disconnect a nonexistent connection from 'Skeleton3D:<Skeleton3D#1772160609762>'. Signal: 'bone_pose_changed', callable: 'BoneAttachment3D::on_bone_pose_update'.
   at: _disconnect (core/object/object.cpp:1327)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.beta.custom_build (ae86d907e75c3de9b039e7cc77e521bc9739e6dc)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fb92c842520] (??:0)
[2] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0x505249d) [0x5556f5df549d] (??:0)
[3] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0x2397159) [0x5556f313a159] (??:0)
[4] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0x1d37768) [0x5556f2ada768] (??:0)
[5] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0x4d215b0) [0x5556f5ac45b0] (??:0)
[6] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0x4a36af6) [0x5556f57d9af6] (??:0)
[7] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0x4d1c75b) [0x5556f5abf75b] (??:0)
[8] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0x4d1cadc) [0x5556f5abfadc] (??:0)
[9] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0x2cc0df4) [0x5556f3a63df4] (??:0)
[10] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0xad9163) [0x5556f187c163] (??:0)
[11] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0xa849e1) [0x5556f18279e1] (??:0)
[12] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0xa7643e) [0x5556f181943e] (??:0)
[13] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fb92c829d90] (??:0)
[14] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7fb92c829e40] (??:0)
[15] /home/mikeysax/Documents/Code/godot/bin/godot.linuxbsd.editor.x86_64(+0xa82a75) [0x5556f1825a75] (??:0)
-- END OF BACKTRACE --
================================================================
qarmin commented 1 year ago

Looks that there is no debug symbols inside the file.

Can you try this binaries? https://github.com/qarmin/GodotBuilds/actions -> Linux Builds 4 -> linux4-editor-sanitizers (or if not works - linux4-editor-normal)

Mikeysax commented 1 year ago

@qarmin Here is the linux4-editor-sanitizers end of the output once I've selected a project:

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.beta.custom_build (ae86d907e75c3de9b039e7cc77e521bc9739e6dc)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /home/mikeysax/Documents/godot.linuxbsd.editor.dev.x86_64.san() [0x26fb17c] (/home/runner/work/GodotBuilds/GodotBuilds/godot/platform/linuxbsd/crash_handler_linuxbsd.cpp:56)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fc0e5c42520] (??:0)
[3] /home/mikeysax/Documents/godot.linuxbsd.editor.dev.x86_64.san(__dynamic_cast+0x4f) [0x20639fbf] (??:?)
[4] Node3D* Object::cast_to<Node3D>(Object*) (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/object/object.h:754 (discriminator 1))
[5] Node3DEditor::_request_gizmo(Object*) (/home/runner/work/GodotBuilds/GodotBuilds/godot/editor/plugins/node_3d_editor_plugin.cpp:7616)
[6] void call_with_variant_args_helper<__UnexistingClass, Object*, 0ul>(__UnexistingClass*, void (__UnexistingClass::*)(Object*), Variant const**, Callable::CallError&, IndexSequence<0ul>) (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/variant/binder_common.h:267 (discriminator 4))
[7] void call_with_variant_args_dv<__UnexistingClass, Object*>(__UnexistingClass*, void (__UnexistingClass::*)(Object*), Variant const**, int, Callable::CallError&, Vector<Variant> const&) (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/variant/binder_common.h:380)
[8] MethodBindT<Object*>::call(Object*, Variant const**, int, Callable::CallError&) const (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/object/method_bind.h:320)
[9] Object::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/GodotBuilds/GodotBuilds/godot/core/object/object.cpp:733 (discriminator 1))
[10] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (/home/runner/work/GodotBuilds/GodotBuilds/godot/core/variant/callable.cpp:62)
[11] MessageQueue::_call_function(Callable const&, Variant const*, int, bool) (/home/runner/work/GodotBuilds/GodotBuilds/godot/core/object/message_queue.cpp:230)
[12] MessageQueue::flush() (/home/runner/work/GodotBuilds/GodotBuilds/godot/core/object/message_queue.cpp:277)
[13] SceneTree::process(double) (/home/runner/work/GodotBuilds/GodotBuilds/godot/scene/main/scene_tree.cpp:470 (discriminator 4))
[14] Main::iteration() (/home/runner/work/GodotBuilds/GodotBuilds/godot/main/main.cpp:3192)
[15] OS_LinuxBSD::run() (/home/runner/work/GodotBuilds/GodotBuilds/godot/platform/linuxbsd/os_linuxbsd.cpp:878)
[16] /home/mikeysax/Documents/godot.linuxbsd.editor.dev.x86_64.san(main+0x58f) [0x26fab45] (/home/runner/work/GodotBuilds/GodotBuilds/godot/platform/linuxbsd/godot_linuxbsd.cpp:75)
[17] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fc0e5c29d90] (??:0)
[18] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7fc0e5c29e40] (??:0)
[19] /home/mikeysax/Documents/godot.linuxbsd.editor.dev.x86_64.san(_start+0x25) [0x26fa4f5] (??:?)
-- END OF BACKTRACE --
================================================================

Let me know if you need more than that, because there was a lot of output before that as well

timothyqiu commented 1 year ago

The backtrace crashes at line 7616 here:

https://github.com/godotengine/godot/blob/ae86d907e75c3de9b039e7cc77e521bc9739e6dc/editor/plugins/node_3d_editor_plugin.cpp#L7615-L7619

The dynamic_cast in Object::cast_to() should not crash for a null pointer, so I guess it's something related to a previously freed object.

68682 adds several calls to Node3D::update_gizmo() which creates that deferred _request_gizmo().

https://github.com/godotengine/godot/blob/ae86d907e75c3de9b039e7cc77e521bc9739e6dc/scene/3d/node_3d.cpp#L484-L487

I can't reproduce this with my project created in beta7. @Mikeysax, can you upload a minimal reproduction project so it's easier to troubleshoot?

Mikeysax commented 1 year ago

@timothyqiu I won't be able to for a day or two as I won't have access a machine

timothyqiu commented 1 year ago

@Mikeysax Can you try this patch? After making a deferred call to _request_gizmo(), there's chance that the argument object go invalid before the call is executed. I changed the deferred calls to use ObjectID instead of raw pointer, so this probably helps.

diff --git i/editor/plugins/node_3d_editor_plugin.cpp w/editor/plugins/node_3d_editor_plugin.cpp
index 112a3fa51b..f5dd893377 100644
--- i/editor/plugins/node_3d_editor_plugin.cpp
+++ w/editor/plugins/node_3d_editor_plugin.cpp
@@ -7639,6 +7639,13 @@ void Node3DEditor::_request_gizmo(Object *p_obj) {
    }
 }

+void Node3DEditor::_request_gizmo_for_id(ObjectID p_id) {
+   Node3D *node = Object::cast_to<Node3D>(ObjectDB::get_instance(p_id));
+   if (node) {
+       _request_gizmo(node);
+   }
+}
+
 void Node3DEditor::_set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform) {
    if (p_id == -1) {
        _clear_subgizmo_selection(p_obj);
@@ -7819,6 +7826,7 @@ void Node3DEditor::_register_all_gizmos() {
 void Node3DEditor::_bind_methods() {
    ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data);
    ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo);
+   ClassDB::bind_method("_request_gizmo_for_id", &Node3DEditor::_request_gizmo_for_id);
    ClassDB::bind_method("_set_subgizmo_selection", &Node3DEditor::_set_subgizmo_selection);
    ClassDB::bind_method("_clear_subgizmo_selection", &Node3DEditor::_clear_subgizmo_selection);
    ClassDB::bind_method("_refresh_menu_icons", &Node3DEditor::_refresh_menu_icons);
diff --git i/editor/plugins/node_3d_editor_plugin.h w/editor/plugins/node_3d_editor_plugin.h
index ed555d86c3..fc252822c4 100644
--- i/editor/plugins/node_3d_editor_plugin.h
+++ w/editor/plugins/node_3d_editor_plugin.h
@@ -716,6 +716,7 @@ private:
    Node3D *selected = nullptr;

    void _request_gizmo(Object *p_obj);
+   void _request_gizmo_for_id(ObjectID p_id);
    void _set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D());
    void _clear_subgizmo_selection(Object *p_obj = nullptr);

diff --git i/scene/3d/node_3d.cpp w/scene/3d/node_3d.cpp
index 1327bdd6e9..a60ccd2169 100644
--- i/scene/3d/node_3d.cpp
+++ w/scene/3d/node_3d.cpp
@@ -188,7 +188,7 @@ void Node3D::_notification(int p_what) {

 #ifdef TOOLS_ENABLED
            if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) {
-               get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
+               get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SNAME("_request_gizmo_for_id"), get_instance_id());
            }
 #endif
        } break;
@@ -482,7 +482,7 @@ void Node3D::update_gizmos() {
    }

    if (data.gizmos.is_empty()) {
-       get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
+       get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SNAME("_request_gizmo_for_id"), get_instance_id());
        return;
    }
    if (data.gizmos_dirty) {
Mikeysax commented 1 year ago

@Mikeysax Can you try this patch? After making a deferred call to _request_gizmo(), there's chance that the argument object go invalid before the call is executed. I changed the deferred calls to use ObjectID instead of raw pointer, so this probably helps.

diff --git i/editor/plugins/node_3d_editor_plugin.cpp w/editor/plugins/node_3d_editor_plugin.cpp
index 112a3fa51b..f5dd893377 100644
--- i/editor/plugins/node_3d_editor_plugin.cpp
+++ w/editor/plugins/node_3d_editor_plugin.cpp
@@ -7639,6 +7639,13 @@ void Node3DEditor::_request_gizmo(Object *p_obj) {
  }
 }

+void Node3DEditor::_request_gizmo_for_id(ObjectID p_id) {
+ Node3D *node = Object::cast_to<Node3D>(ObjectDB::get_instance(p_id));
+ if (node) {
+     _request_gizmo(node);
+ }
+}
+
 void Node3DEditor::_set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform) {
  if (p_id == -1) {
      _clear_subgizmo_selection(p_obj);
@@ -7819,6 +7826,7 @@ void Node3DEditor::_register_all_gizmos() {
 void Node3DEditor::_bind_methods() {
  ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data);
  ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo);
+ ClassDB::bind_method("_request_gizmo_for_id", &Node3DEditor::_request_gizmo_for_id);
  ClassDB::bind_method("_set_subgizmo_selection", &Node3DEditor::_set_subgizmo_selection);
  ClassDB::bind_method("_clear_subgizmo_selection", &Node3DEditor::_clear_subgizmo_selection);
  ClassDB::bind_method("_refresh_menu_icons", &Node3DEditor::_refresh_menu_icons);
diff --git i/editor/plugins/node_3d_editor_plugin.h w/editor/plugins/node_3d_editor_plugin.h
index ed555d86c3..fc252822c4 100644
--- i/editor/plugins/node_3d_editor_plugin.h
+++ w/editor/plugins/node_3d_editor_plugin.h
@@ -716,6 +716,7 @@ private:
  Node3D *selected = nullptr;

  void _request_gizmo(Object *p_obj);
+ void _request_gizmo_for_id(ObjectID p_id);
  void _set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D());
  void _clear_subgizmo_selection(Object *p_obj = nullptr);

diff --git i/scene/3d/node_3d.cpp w/scene/3d/node_3d.cpp
index 1327bdd6e9..a60ccd2169 100644
--- i/scene/3d/node_3d.cpp
+++ w/scene/3d/node_3d.cpp
@@ -188,7 +188,7 @@ void Node3D::_notification(int p_what) {

 #ifdef TOOLS_ENABLED
          if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) {
-             get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
+             get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SNAME("_request_gizmo_for_id"), get_instance_id());
          }
 #endif
      } break;
@@ -482,7 +482,7 @@ void Node3D::update_gizmos() {
  }

  if (data.gizmos.is_empty()) {
-     get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
+     get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SNAME("_request_gizmo_for_id"), get_instance_id());
      return;
  }
  if (data.gizmos_dirty) {

That did it! I applied those changes,ie:

➜  godot git:(master) ✗ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   editor/plugins/node_3d_editor_plugin.cpp
    modified:   editor/plugins/node_3d_editor_plugin.h
    modified:   scene/3d/node_3d.cpp

no changes added to commit (use "git add" and/or "git commit -a")
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 112a3fa51b..f5dd893377 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -7639,6 +7639,13 @@ void Node3DEditor::_request_gizmo(Object *p_obj) {
        }
 }

+void Node3DEditor::_request_gizmo_for_id(ObjectID p_id) {
+       Node3D *node = Object::cast_to<Node3D>(ObjectDB::get_instance(p_id));
+       if (node) {
+               _request_gizmo(node);
+       }
+}
+
 void Node3DEditor::_set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform) {
        if (p_id == -1) {
                _clear_subgizmo_selection(p_obj);
@@ -7819,6 +7826,7 @@ void Node3DEditor::_register_all_gizmos() {
 void Node3DEditor::_bind_methods() {
        ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data);
        ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo);
+       ClassDB::bind_method("_request_gizmo_for_id", &Node3DEditor::_request_gizmo_for_id);
        ClassDB::bind_method("_set_subgizmo_selection", &Node3DEditor::_set_subgizmo_selection);
        ClassDB::bind_method("_clear_subgizmo_selection", &Node3DEditor::_clear_subgizmo_selection);
        ClassDB::bind_method("_refresh_menu_icons", &Node3DEditor::_refresh_menu_icons);
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index ed555d86c3..fc252822c4 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -716,6 +716,7 @@ private:
        Node3D *selected = nullptr;

        void _request_gizmo(Object *p_obj);
+       void _request_gizmo_for_id(ObjectID p_id);
        void _set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D());
        void _clear_subgizmo_selection(Object *p_obj = nullptr);

diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index 1327bdd6e9..a60ccd2169 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -188,7 +188,7 @@ void Node3D::_notification(int p_what) {

 #ifdef TOOLS_ENABLED
                        if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) {
-                               get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
+                               get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SNAME("_request_gizmo_for_id"), get_instance_id());
                        }
 #endif
                } break;
@@ -482,7 +482,7 @@ void Node3D::update_gizmos() {
        }

        if (data.gizmos.is_empty()) {
-               get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
+               get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SNAME("_request_gizmo_for_id"), get_instance_id());
                return;
        }

if (data.gizmos_dirty) {
(END)
[100%] Linking Program bin/godot.linuxbsd.editor.x86_64 ...
[100%] scons: done building targets.
[Time elapsed: 00:08:44.029]
➜  godot git:(master) ✗ ./bin/godot.linuxbsd.editor.x86_64 
Godot Engine v4.0.beta.custom_build.ae86d907e - https://godotengine.org
OpenGL Renderer: REMBRANDT (rembrandt, LLVM 14.0.0, DRM 3.48, 6.0.6-76060006-generic)

Editing project: /home/mikeysax/Documents/Code/maskless
Godot Engine v4.0.beta.custom_build.ae86d907e - https://godotengine.org
Vulkan API 1.3.224 - Using Vulkan Device #1: AMD - AMD Radeon RX 6700M (RADV NAVI22)
➜  godot git:(master) ✗  

@timothyqiu :+1:

Sauermann commented 1 year ago

duplicate of #69459 (same cause)