Repository: godot
Issue: Crash in Language Server (LSP) while game is running
Labels: bug,topic:gdscript,topic:editor,crash

### Tested versions

4.3.1.rc.custom_build.90f21a35c
4.3.stable

### System information

Godot v4.3.1.rc (90f21a35c) - Arch Linux #1 SMP PREEMPT_DYNAMIC Sat, 18 Jan 2025 02:26:57 +0000 - Wayland - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (nvidia; 565.77) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)

### Issue description

Godot periodically crashes while my game is running in the editor. The game itself keeps running, but the editor crashes and closes.
It's not obvious exactly what triggers this, but I have a LSP client attached, and the crash appears to be in the LSP code.

```
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007805ffdcd463 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
#2  0x00007805ffd74120 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007805ffd5b4c3 in __GI_abort () at abort.c:79
#4  0x000056edddc44dfb in handle_crash (sig=<optimized out>) at platform/linuxbsd/crash_handler_linuxbsd.cpp:145
#5  <signal handler called>
#6  0x000056ede20199c1 in Variant::reference (this=0x78059d9f9b70, p_variant=...) at core/variant/variant.cpp:1159
#7  0x000056ede0cc4b1c in Variant::Variant (this=0x78059d9f9b70, p_variant=...) at core/variant/variant.cpp:2922
#8  SceneState::instantiate (this=<optimized out>, p_edit_state=p_edit_state@entry=SceneState::GEN_EDIT_STATE_DISABLED) at scene/resources/packed_scene.cpp:357
#9  0x000056ede0cc9357 in PackedScene::instantiate (this=this@entry=0x56ee1f2609d0, p_edit_state=p_edit_state@entry=PackedScene::GEN_EDIT_STATE_DISABLED) at ./core/object/ref_counted.h:104
#10 0x000056ede0cc4d2d in SceneState::instantiate (this=<optimized out>, p_edit_state=p_edit_state@entry=SceneState::GEN_EDIT_STATE_DISABLED) at scene/resources/packed_scene.cpp:232
#11 0x000056ede0cc9357 in PackedScene::instantiate (this=0x56ee2048d1c0, p_edit_state=PackedScene::GEN_EDIT_STATE_DISABLED) at ./core/object/ref_counted.h:104
#12 0x000056edde082b10 in GDScriptWorkspace::_get_owner_scene_node (this=0x56ee11f66740, p_path=...) at modules/gdscript/language_server/gdscript_workspace.cpp:627
#13 GDScriptWorkspace::completion (this=0x56ee11f66740, p_params=..., r_options=0x78059d9fa130) at modules/gdscript/language_server/gdscript_workspace.cpp:641
#14 GDScriptTextDocument::completion (this=<optimized out>, p_params=...) at modules/gdscript/language_server/gdscript_text_document.cpp:182
#15 0x000056edde0e6eb7 in call_with_variant_args_ret_helper<__UnexistingClass, Array, Dictionary const&, 0ul> (p_instance=<optimized out>, p_method=<optimized out>, p_args=<synthetic pointer>, r_ret=..., r_error=...) at ./core/variant/binder_common.h:756
#16 call_with_variant_args_ret_dv<__UnexistingClass, Array, Dictionary const&> (p_instance=<optimized out>, p_method=<optimized out>, p_args=<optimized out>, p_argcount=<optimized out>, r_ret=..., r_error=..., default_values=...) at ./core/variant/binder_common.h:535
#17 MethodBindTR<Array, Dictionary const&>::call (this=<optimized out>, p_object=<optimized out>, p_args=<optimized out>, p_arg_count=<optimized out>, r_error=...) at ./core/object/method_bind.h:524
#18 0x000056ede22489d6 in Object::callp (this=0x56ee169a3820, p_method=..., p_args=<optimized out>, p_argcount=<optimized out>, r_error=...) at core/object/object.cpp:811
#19 0x000056ede2226dd1 in Object::callv (this=0x56ee169a3820, p_method=..., p_args=...) at core/object/object.cpp:749
#20 0x000056edde3b2b17 in JSONRPC::process_action (this=this@entry=0x56ee169a3018, p_action=..., p_process_arr_elements=p_process_arr_elements@entry=true) at modules/jsonrpc/jsonrpc.cpp:130
#21 0x000056edde3b37bc in JSONRPC::process_string (this=0x56ee169a3018, p_input=...) at modules/jsonrpc/jsonrpc.cpp:162
#22 0x000056edde02b1d0 in GDScriptLanguageProtocol::process_message (this=<optimized out>, p_text=...) at modules/gdscript/language_server/gdscript_language_protocol.cpp:143
#23 GDScriptLanguageProtocol::LSPeer::handle_data (this=0x78057000af50) at modules/gdscript/language_server/gdscript_language_protocol.cpp:98
#24 GDScriptLanguageProtocol::poll (this=this@entry=0x56ee169a3018, p_limit_usec=<optimized out>) at modules/gdscript/language_server/gdscript_language_protocol.cpp:252
#25 0x000056edde02b760 in GDScriptLanguageServer::thread_main (p_userdata=0x56ee169a29c0) at modules/gdscript/language_server/gdscript_language_server.cpp:88
#26 0x000056ede1d0ae5d in Thread::callback (p_caller_id=<optimized out>, p_settings=..., p_callback=0x56edde02b700 <GDScriptLanguageServer::thread_main(void*)>, p_userdata=0x56ee169a29c0) at core/os/thread.cpp:64
#27 0x000056edddbb7264 in execute_native_thread_routine ()
#28 0x00007805ffdcb39d in start_thread (arg=<optimized out>) at pthread_create.c:447
#29 0x00007805ffe5049c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
```

It appears to have something to do with setting a variant to a Transform3D?

```
(gdb) frame 6
#6  0x000056ede20199c1 in Variant::reference (this=0x78059d9f9b70, p_variant=...) at core/variant/variant.cpp:1159
1159				memnew_placement(_data._transform3d, Transform3D(*p_variant._data._transform3d));
(gdb) l
1154				_data._basis = (Basis *)Pools::_bucket_medium.alloc();
1155				memnew_placement(_data._basis, Basis(*p_variant._data._basis));
1156			} break;
1157			case TRANSFORM3D: {
1158				_data._transform3d = (Transform3D *)Pools::_bucket_medium.alloc();
1159				memnew_placement(_data._transform3d, Transform3D(*p_variant._data._transform3d));
1160			} break;
1161			case PROJECTION: {
1162				_data._projection = (Projection *)Pools::_bucket_large.alloc();
1163				memnew_placement(_data._projection, Projection(*p_variant._data._projection));
(gdb) p p_variant
$4 = (const Variant &) @0x56ee2343e520: {type = Variant::TRANSFORM3D, _data = {_bool = false, _int = 0, _float = 0, _transform2d = 0x0, _aabb = 0x0, _basis = 0x0, _transform3d = 0x0, _projection = 0x0, packed_array = 0x0, _ptr = 0x0, _mem = '\000' <repeats 15 times>}}
(gdb) p _data
$5 = {_bool = 144, _int = 131967152792464, _float = 6.5200436574239189e-310, _transform2d = 0x7805ff43a390, _aabb = 0x7805ff43a390, _basis = 0x7805ff43a390, _transform3d = 0x7805ff43a390, _projection = 0x7805ff43a390, packed_array = 0x7805ff43a390, _ptr = 0x7805ff43a390, 
  _mem = "\220\243C\377\005x\000\000\000\000\000\000\000\000\000"}
```

### Steps to reproduce

1. Open a godot project
2. Open an editor with a LSP client
3. Launch the game
4. Play the game for a bit
5. The editor crashes

### Minimal reproduction project (MRP)

I don't have a minimal project, but here's the one I've reproed in many times:
https://github.com/rcorre/zambus