Repository: godot
Issue: Godot 4.1.x crash at startup
Labels: platform:linuxbsd,topic:porting,needs testing

### Godot version

4.1.1

### System information

Linux

### Issue description

Godot is crashing for me today, I tried both 4.1 and 4.1.1, it opens the project selection screen, and if I select a project that have a 3d scene showing it crashes, if I select a project with pure code it works.
The log above, shows it cant open a new opengl client, I am not sure why. I think if I restart the system it will start to work again, so I wander if its a bug of not releasing something or checking for something it should not be checking.

A note, I use godot for a while and its the first time it happens, something I think could be causing it its the use of remote development ( with sunshine in my case ), maybe its not releasing the opengl instance somehow ? Is it possible to have a parameter to ignore this error ?

```
wagner@tuf123:~$ /opt/Godot_v4.1-stable_linux.x86_64 --rendering-driver opengl3
Godot Engine v4.1.stable.official.970459615 - https://godotengine.org
WARNING: XOpenIM failed
     at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:5634)
Maximum number of clients reached
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.stable.official (970459615f6b2b4151742ec6d7ef8559f87fd5c5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f92431d6520] (??:0)
[2] /lib/x86_64-linux-gnu/libX11.so.6(XDefaultScreenOfDisplay+0x4) [0x7f923c4a7e44] (??:0)
[3] /opt/Godot_v4.1-stable_linux.x86_64() [0xeff44c] (??:0)
[4] /opt/Godot_v4.1-stable_linux.x86_64() [0xec467d] (??:0)
[5] /opt/Godot_v4.1-stable_linux.x86_64() [0xec4d8f] (??:0)
[6] /opt/Godot_v4.1-stable_linux.x86_64() [0x4cb49f1] (??:0)
[7] /opt/Godot_v4.1-stable_linux.x86_64() [0xf44cb2] (??:0)
[8] /opt/Godot_v4.1-stable_linux.x86_64() [0xe4b46d] (??:0)
[9] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f92431bdd90] (??:0)
[10] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f92431bde40] (??:0)
[11] /opt/Godot_v4.1-stable_linux.x86_64() [0xe76cee] (??:0)
-- END OF BACKTRACE --
================================================================
Maximum number of clients reached
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.stable.official (970459615f6b2b4151742ec6d7ef8559f87fd5c5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f92431d6520] (??:0)
[2] /lib/x86_64-linux-gnu/libX11.so.6(XDefaultScreenOfDisplay+0x4) [0x7f923c4a7e44] (??:0)
[3] /opt/Godot_v4.1-stable_linux.x86_64() [0xeff44c] (??:0)
[4] /opt/Godot_v4.1-stable_linux.x86_64() [0xec467d] (??:0)
[5] /opt/Godot_v4.1-stable_linux.x86_64() [0xec4d8f] (??:0)
[6] /opt/Godot_v4.1-stable_linux.x86_64() [0x4cb49f1] (??:0)
[7] /opt/Godot_v4.1-stable_linux.x86_64() [0xf44cb2] (??:0)
[8] /opt/Godot_v4.1-stable_linux.x86_64() [0xe4b46d] (??:0)
[9] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f92431bdd90] (??:0)
[10] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f92431bde40] (??:0)
[11] /opt/Godot_v4.1-stable_linux.x86_64() [0xe76cee] (??:0)
-- END OF BACKTRACE --
================================================================
WARNING: XCreateIC couldn't create wd.xic
     at: _create_window (platform/linuxbsd/x11/display_server_x11.cpp:5260)
OpenGL API 4.6 (Core Profile) Mesa 22.2.5-0ubuntu0.1~22.04.3 - Compatibility - Using Device: AMD - AMD Radeon RX 5500 XT (navi14, LLVM 15.0.7, DRM 3.42, 5.15.0-78-generic)
 
Editing project: /home/wagner/Desktop/New Games Project/Prototypes/TankRank
Godot Engine v4.1.stable.official.970459615 - https://godotengine.org
Maximum number of clients reachedERROR: X11 Display is not available
   at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:5499)
Maximum number of clients reached
(zenity:244097): Gtk-WARNING **: 10:16:33.191: cannot open display: :0
ERROR: Unable to create DisplayServer, all display drivers failed.
   at: setup2 (main/main.cpp:2212)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools11BucketLargeE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools12BucketMediumE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools11BucketSmallE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: BUG: Unreferenced static string to 0: TextServerDummy
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: IPUnix
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatImporterSaver
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: MovieWriterMJPEG
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: interface_added
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: TextServerAdvanced
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ImageFormatLoader
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatSaver
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: GDScriptEditorTranslationParserPlugin
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: MovieWriterPNGWAV
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ScriptLanguage
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatLoader
   at: unref (core/string/string_name.cpp:131)
wagner@tuf123:~$ /opt/Godot_v4.1-stable_linux.x86_64
Godot Engine v4.1.stable.official.970459615 - https://godotengine.org
WARNING: XOpenIM failed
     at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:5634)
Maximum number of clients reached
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.stable.official (970459615f6b2b4151742ec6d7ef8559f87fd5c5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f05e4b82520] (??:0)
[2] /lib/x86_64-linux-gnu/libX11.so.6(XDefaultScreenOfDisplay+0x4) [0x7f05dde53e44] (??:0)
[3] /opt/Godot_v4.1-stable_linux.x86_64() [0xeff44c] (??:0)
[4] /opt/Godot_v4.1-stable_linux.x86_64() [0xec467d] (??:0)
[5] /opt/Godot_v4.1-stable_linux.x86_64() [0xec4d8f] (??:0)
[6] /opt/Godot_v4.1-stable_linux.x86_64() [0x4cb49f1] (??:0)
[7] /opt/Godot_v4.1-stable_linux.x86_64() [0xf44cb2] (??:0)
[8] /opt/Godot_v4.1-stable_linux.x86_64() [0xe4b46d] (??:0)
[9] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f05e4b69d90] (??:0)
[10] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f05e4b69e40] (??:0)
[11] /opt/Godot_v4.1-stable_linux.x86_64() [0xe76cee] (??:0)
-- END OF BACKTRACE --
================================================================
Maximum number of clients reached
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.stable.official (970459615f6b2b4151742ec6d7ef8559f87fd5c5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f05e4b82520] (??:0)
[2] /lib/x86_64-linux-gnu/libX11.so.6(XDefaultScreenOfDisplay+0x4) [0x7f05dde53e44] (??:0)
[3] /opt/Godot_v4.1-stable_linux.x86_64() [0xeff44c] (??:0)
[4] /opt/Godot_v4.1-stable_linux.x86_64() [0xec467d] (??:0)
[5] /opt/Godot_v4.1-stable_linux.x86_64() [0xec4d8f] (??:0)
[6] /opt/Godot_v4.1-stable_linux.x86_64() [0x4cb49f1] (??:0)
[7] /opt/Godot_v4.1-stable_linux.x86_64() [0xf44cb2] (??:0)
[8] /opt/Godot_v4.1-stable_linux.x86_64() [0xe4b46d] (??:0)
[9] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f05e4b69d90] (??:0)
[10] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f05e4b69e40] (??:0)
[11] /opt/Godot_v4.1-stable_linux.x86_64() [0xe76cee] (??:0)
-- END OF BACKTRACE --
================================================================
WARNING: XCreateIC couldn't create wd.xic
     at: _create_window (platform/linuxbsd/x11/display_server_x11.cpp:5260)
OpenGL API 4.6 (Core Profile) Mesa 22.2.5-0ubuntu0.1~22.04.3 - Compatibility - Using Device: AMD - AMD Radeon RX 5500 XT (navi14, LLVM 15.0.7, DRM 3.42, 5.15.0-78-generic)
 
Editing project: /home/wagner/Desktop/New Games Project/Prototypes/TankRank
Godot Engine v4.1.stable.official.970459615 - https://godotengine.org
Maximum number of clients reachedERROR: X11 Display is not available
   at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:5499)
Maximum number of clients reached
(zenity:244200): Gtk-WARNING **: 10:17:28.795: cannot open display: :0
ERROR: Unable to create DisplayServer, all display drivers failed.
   at: setup2 (main/main.cpp:2212)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools11BucketLargeE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools12BucketMediumE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools11BucketSmallE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: BUG: Unreferenced static string to 0: TextServerDummy
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: IPUnix
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatImporterSaver
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: MovieWriterMJPEG
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: interface_added
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: TextServerAdvanced
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ImageFormatLoader
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatSaver
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: GDScriptEditorTranslationParserPlugin
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: MovieWriterPNGWAV
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ScriptLanguage
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatLoader
   at: unref (core/string/string_name.cpp:131)
wagner@tuf123:~$ /opt/Godot_v4.1.1-stable_linux.x86_64
Godot Engine v4.1.1.stable.official.bd6af8e0e - https://godotengine.org
WARNING: XOpenIM failed
     at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:5638)
Maximum number of clients reached
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.1.stable.official (bd6af8e0ea69167dd0627f3bd54f9105bda0f8b5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fae585c0520] (??:0)
[2] /lib/x86_64-linux-gnu/libX11.so.6(XDefaultScreenOfDisplay+0x4) [0x7fae51891e44] (??:0)
[3] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xeffd0c] (??:0)
[4] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xec4f3d] (??:0)
[5] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xec564f] (??:0)
[6] /opt/Godot_v4.1.1-stable_linux.x86_64() [0x4cb8d41] (??:0)
[7] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xf45512] (??:0)
[8] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xe4be3d] (??:0)
[9] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fae585a7d90] (??:0)
[10] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7fae585a7e40] (??:0)
[11] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xe777ae] (??:0)
-- END OF BACKTRACE --
================================================================
Maximum number of clients reached
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.1.stable.official (bd6af8e0ea69167dd0627f3bd54f9105bda0f8b5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fae585c0520] (??:0)
[2] /lib/x86_64-linux-gnu/libX11.so.6(XDefaultScreenOfDisplay+0x4) [0x7fae51891e44] (??:0)
[3] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xeffd0c] (??:0)
[4] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xec4f3d] (??:0)
[5] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xec564f] (??:0)
[6] /opt/Godot_v4.1.1-stable_linux.x86_64() [0x4cb8d41] (??:0)
[7] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xf45512] (??:0)
[8] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xe4be3d] (??:0)
[9] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fae585a7d90] (??:0)
[10] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7fae585a7e40] (??:0)
[11] /opt/Godot_v4.1.1-stable_linux.x86_64() [0xe777ae] (??:0)
-- END OF BACKTRACE --
================================================================
WARNING: XCreateIC couldn't create wd.xic
     at: _create_window (platform/linuxbsd/x11/display_server_x11.cpp:5260)
OpenGL API 4.6 (Core Profile) Mesa 22.2.5-0ubuntu0.1~22.04.3 - Compatibility - Using Device: AMD - AMD Radeon RX 5500 XT (navi14, LLVM 15.0.7, DRM 3.42, 5.15.0-78-generic)
 
Editing project: /home/wagner/Desktop/New Games Project/Prototypes/TankRank
Godot Engine v4.1.1.stable.official.bd6af8e0e - https://godotengine.org
Maximum number of clients reachedERROR: X11 Display is not available
   at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:5503)
Maximum number of clients reached
(zenity:244578): Gtk-WARNING **: 10:20:52.925: cannot open display: :0
ERROR: Unable to create DisplayServer, all display drivers failed.
   at: setup2 (main/main.cpp:2216)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools11BucketLargeE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools12BucketMediumE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: Pages in use exist at exit in PagedAllocator: N7Variant5Pools11BucketSmallE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: BUG: Unreferenced static string to 0: TextServerDummy
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: IPUnix
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatImporterSaver
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: MovieWriterMJPEG
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: interface_added
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: TextServerAdvanced
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ImageFormatLoader
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatSaver
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: GDScriptEditorTranslationParserPlugin
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: MovieWriterPNGWAV
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ScriptLanguage
   at: unref (core/string/string_name.cpp:131)
ERROR: BUG: Unreferenced static string to 0: ResourceFormatLoader
   at: unref (core/string/string_name.cpp:131)
```

### Steps to reproduce

Not sure, I suspect that if you use sunshine+monligth to dev remotly it will get into it eventually, but I am not sure this is the case.

### Minimal reproduction project

I tried several projects, the ones that got problem was anything that shows a rendering screen in startup, when opening a project that opens the screen in the code mode, it works until I open a screen.