Repository: godot
Issue: Renderer crash (dev assert) on exiting the editor in dev build
Labels: bug,topic:rendering,crash

### Godot version

4.1 caa8c825671a04f89e046de2207e073acde2651e

### System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

### Issue description

I was using a dev build of the editor with a C++ debugger attached.
I mostly edited a large GDScript file while one UI scene was open, then I closed the editor and it crashed with the following call stack:

```
godot.windows.editor.dev.x86_64.exe!SelfList<RendererSceneRenderImplementation::RenderForwardClustered::GeometryInstanceForwardClustered>::List::~List() Line 114 (godot4_fork\core\templates\self_list.h:114)
godot.windows.editor.dev.x86_64.exe!RendererSceneRenderImplementation::RenderForwardClustered::~RenderForwardClustered() Line 4045 (godot4_fork\servers\rendering\renderer_rd\forward_clustered\render_forward_clustered.cpp:4045)
godot.windows.editor.dev.x86_64.exe!RendererSceneRenderImplementation::RenderForwardClustered::`scalar deleting destructor'(unsigned int) (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!memdelete<RendererSceneRenderRD>(RendererSceneRenderRD * p_class) Line 112 (godot4_fork\core\os\memory.h:112)
godot.windows.editor.dev.x86_64.exe!RendererCompositorRD::finalize() Line 150 (godot4_fork\servers\rendering\renderer_rd\renderer_compositor_rd.cpp:150)
godot.windows.editor.dev.x86_64.exe!RenderingServerDefault::_finish() Line 218 (godot4_fork\servers\rendering\rendering_server_default.cpp:218)
godot.windows.editor.dev.x86_64.exe!RenderingServerDefault::finish() Line 246 (godot4_fork\servers\rendering\rendering_server_default.cpp:246)
godot.windows.editor.dev.x86_64.exe!finalize_display() Line 314 (godot4_fork\main\main.cpp:314)
godot.windows.editor.dev.x86_64.exe!Main::cleanup(bool p_force) Line 3631 (godot4_fork\main\main.cpp:3631)
godot.windows.editor.dev.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 184 (godot4_fork\platform\windows\godot_windows.cpp:184)
godot.windows.editor.dev.x86_64.exe!_main() Line 204 (godot4_fork\platform\windows\godot_windows.cpp:204)
godot.windows.editor.dev.x86_64.exe!main(int argc, char * * argv) Line 218 (godot4_fork\platform\windows\godot_windows.cpp:218)
godot.windows.editor.dev.x86_64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 232 (godot4_fork\platform\windows\godot_windows.cpp:232)
godot.windows.editor.dev.x86_64.exe!invoke_main() Line 107 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:107)
godot.windows.editor.dev.x86_64.exe!__scrt_common_main_seh() Line 288 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
godot.windows.editor.dev.x86_64.exe!__scrt_common_main() Line 331 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331)
godot.windows.editor.dev.x86_64.exe!WinMainCRTStartup(void * __formal) Line 17 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_winmain.cpp:17)
kernel32.dll!00007ffdcb657614() (Unknown Source:0)
ntdll.dll!00007ffdcb8c26b1() (Unknown Source:0)
```

With the following errors in the log:
```
ERROR: Pages in use exist at exit in PagedAllocator: class RendererSceneRenderImplementation::RenderForwardClustered::GeometryInstanceForwardClustered
   at: PagedAllocator<class RendererSceneRenderImplementation::RenderForwardClustered::GeometryInstanceForwardClustered,0>::~PagedAllocator (D:\PROJETS\INFO\GODOT\Engine\godot4_fork\core/templates/paged_allocator.h:170)
D:\PROJETS\INFO\GODOT\Engine\godot4_fork\core/templates/paged_allocator.h:170 - Pages in use exist at exit in PagedAllocator: class RendererSceneRenderImplementation::RenderForwardClustered::GeometryInstanceForwardClustered
ERROR: FATAL: DEV_ASSERT failed  "_first == nullptr" is false.
   at: SelfList<class RendererSceneRenderImplementation::RenderForwardClustered::GeometryInstanceForwardClustered>::List::~List (D:\PROJETS\INFO\GODOT\Engine\godot4_fork\core/templates/self_list.h:114)
D:\PROJETS\INFO\GODOT\Engine\godot4_fork\core/templates/self_list.h:114 - FATAL: DEV_ASSERT failed  "_first == nullptr" is false.
```

### Steps to reproduce

I don't know the cause yet, so all I can do for now is to report the crash, in case someone knows what's up.
I just opened a project, edited a large script containing a bunch of preloads, then closed the editor.
If I have it happen again with more insight, I might update the issue.

### Minimal reproduction project

N.A