Repository: godot
Issue: Occlusion Culling causes a segfault
Labels: bug,topic:rendering,needs testing,crash,topic:3d

### Godot version

4.0 dev

### System information

Arch Linux + X11 + Radeon RX6800XT

### Issue description

In my game [Liblast](https://code.libla.st) recently after adding a new weapon I've noticed a very high frequency of crashes. These seem to have a random chance to occur when the weapon (Plasma Gun) is used, as in crowded games it happens almost instantly, but almost never if I'm running around alone.

I've reproduced the crash and obtained a backtrace (see below). It seems to be happening in occlusion culling, and I can confirm that after disabling that feature the game no longer crashes.

```
Thread 1 "godot.linuxbsd." received signal SIGSEGV, Segmentation fault.
0x0000555556b0fa65 in RaycastOcclusionCull::RaycastHZBuffer::sort_rays (this=this@entry=0x55555fbc5dc8, p_camera_dir=..., p_orthogonal=p_orthogonal@entry=false) at modules/raycast/raycast_occlusion_cull.cpp:193
193                                             mips[0][y * buffer_size.x + x] = d;
(gdb) bt
#0  0x0000555556b0fa65 in RaycastOcclusionCull::RaycastHZBuffer::sort_rays (this=this@entry=0x55555fbc5dc8, p_camera_dir=..., p_orthogonal=p_orthogonal@entry=false) at modules/raycast/raycast_occlusion_cull.cpp:193
#1  0x0000555556b141cf in RaycastOcclusionCull::buffer_update (this=0x55555f83ae60, p_buffer=..., p_cam_transform=..., p_cam_projection=..., p_cam_orthogonal=<optimized out>) at modules/raycast/raycast_occlusion_cull.cpp:557
#2  0x00005555599c5988 in RendererSceneCull::render_camera (this=this@entry=0x55555de5eb60, p_render_buffers=..., p_camera=..., p_scenario=..., p_viewport=..., p_viewport_size=..., p_use_taa=p_use_taa@entry=false, 
    p_screen_mesh_lod_threshold=p_screen_mesh_lod_threshold@entry=0.00117187505, p_shadow_atlas=..., p_xr_interface=..., r_render_info=<optimized out>) at servers/rendering/renderer_scene_cull.cpp:2583
#3  0x0000555559301a9a in RendererViewport::_draw_3d (this=<optimized out>, p_viewport=0x55555ff11120) at servers/rendering/renderer_viewport.cpp:211
#4  0x0000555559303ba5 in RendererViewport::_draw_viewport (this=0x55555da9b050, p_viewport=0x55555ff11120) at servers/rendering/renderer_viewport.cpp:266
#5  0x0000555559306530 in RendererViewport::draw_viewports (this=<optimized out>) at servers/rendering/renderer_viewport.cpp:717
#6  0x0000555559363a3c in RenderingServerDefault::_draw (this=0x55555dcb9520, p_swap_buffers=<optimized out>, frame_step=0.070648000000000002) at servers/rendering/rendering_server_default.cpp:91
#7  0x00005555560627db in Main::iteration () at main/main.cpp:3122
#8  0x0000555556009a71 in OS_LinuxBSD::run (this=this@entry=0x7fffffffda20) at platform/linuxbsd/os_linuxbsd.cpp:878
#9  0x0000555555ffbdb9 in main (argc=<optimized out>, argv=0x7fffffffdf78) at platform/linuxbsd/godot_linuxbsd.cpp:73
```

### Steps to reproduce

No idea :/

### Minimal reproduction project

Unfortunately I don't know what is causing this so the only reproduction I can offer is running my game.

1. **Clone** (not download!) the repository from https://codeberg.org/Liblast/Liblast (you must also install git LFS or it won't work!)
2. To be sure checkout this commit as it's a known reproduction spot: `56c4eee59a0304094ea171b368b5bd594b7ad797`
3. Import the project from `Liblast/Game`
4. Run the game with F5.
5. Select **MapD** from the map dropdown
6. Select "HOST a local game"

![image](https://user-images.githubusercontent.com/491704/213943727-521662f0-a8fd-4c0a-995a-11d3efe17bd5.png)

7. Wait a few seconds
8. Watch the game crashing with no debugger output.