Repository: godot
Issue: Inconsistent crashes when switching scenes
Labels: bug,topic:core,topic:physics,crash,topic:3d

### Godot version

4.0.3.stable

### System information

Arch Linux - RX 570 - Ryzen 5 3400G - Vulkan

### Issue description

When running the project, if I change scenes, for some reason the game sometimes crashes. It can work fine 20 times in a row, and then crash out of the blue, but it always happens when switching scenes, at no other time.

Here is the piece of code I use to change scenes with a transition:

```
extends CanvasLayer

func change_scene_to_file(target: String) -> void:
	$AnimationPlayer.play_backwards("fade")
	await $AnimationPlayer.animation_finished
	get_tree().change_scene_to_file(target)
	$AnimationPlayer.play("fade")

func reload_current_scene() -> void:
	$AnimationPlayer.play_backwards("fade")
	await $AnimationPlayer.animation_finished
	get_tree().reload_current_scene()
	$AnimationPlayer.play("fade")
```

The problem is not me sending an incorrect scene file path. I have corroborated that the path I am giving when it crashes is proper.

I launched godot through the terminal to see what it says when it crashes. Here's the result:

```
Godot Engine v4.0.3.stable.arch_linux - https://godotengine.org
Vulkan API 1.3.246 - Forward+ - Using Vulkan Device #0: AMD - AMD Radeon RX 570 Series (RADV POLARIS10)

ERROR: FATAL: Index p_index = 0 is out of bounds (count = 0).
   at: operator[] (./core/templates/local_vector.h:155)

================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.0.3.stable.arch_linux
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x39ab0) [0x7ff789562ab0] (??:0)
[2] /usr/bin/godot(+0x3da8c91) [0x5560e4399c91] (??:?)
[3] /usr/bin/godot(+0x3d09a4a) [0x5560e42faa4a] (??:?)
[4] /usr/bin/godot(+0x43da93c) [0x5560e49cb93c] (??:?)
[5] /usr/bin/godot(+0x4df1b3c) [0x5560e53e2b3c] (??:?)
[6] /usr/bin/godot(+0x4423665) [0x5560e4a14665] (??:?)
[7] /usr/bin/godot(+0x4a6fbc5) [0x5560e5060bc5] (??:?)
[8] /usr/bin/godot(+0x4425009) [0x5560e4a16009] (??:?)
[9] /usr/bin/godot(+0x420c1ec) [0x5560e47fd1ec] (??:?)
[10] /usr/bin/godot(+0x3d8c58b) [0x5560e437d58b] (??:?)
[11] /usr/bin/godot(+0x3d8c58b) [0x5560e437d58b] (??:?)
[12] /usr/bin/godot(+0x3d8c58b) [0x5560e437d58b] (??:?)
[13] /usr/bin/godot(+0x3d8c58b) [0x5560e437d58b] (??:?)
[14] /usr/bin/godot(+0x3de039a) [0x5560e43d139a] (??:?)
[15] /usr/bin/godot(+0x4230fee) [0x5560e4821fee] (??:?)
[16] /usr/bin/godot(+0x3de3db5) [0x5560e43d4db5] (??:?)
[17] /usr/bin/godot(+0x3338e86) [0x5560e3929e86] (??:?)
[18] /usr/bin/godot(+0x48ba7a8) [0x5560e4eab7a8] (??:?)
[19] /usr/bin/godot(+0x2e2d545) [0x5560e341e545] (??:?)
[20] /usr/bin/godot(+0x2e8a234) [0x5560e347b234] (??:?)
[21] /usr/bin/godot(+0x10fbd89) [0x5560e16ecd89] (??:?)
[22] /usr/bin/godot(+0x10a18b9) [0x5560e16928b9] (??:?)
[23] /usr/lib/libc.so.6(+0x23850) [0x7ff78954c850] (??:0)
[24] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7ff78954c90a] (??:0)
[25] /usr/bin/godot(+0x10afda5) [0x5560e16a0da5] (??:?)
-- END OF BACKTRACE --
================================================================
```

### Steps to reproduce

1. Change scenes with `get_tree().change_scene_to_file()`
2. With some "luck"... crash

### Minimal reproduction project

N/A