godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.84k stars 20.15k forks source link

Vulkan: Godot Engine 4.4.dev crashes on startup on Linux and Windows #95967

Closed ywmaa closed 2 weeks ago

ywmaa commented 3 weeks ago

Tested versions

last commit in 4.4 dev: 568589c9d8c763bfb3a4348174d53b42d7c59f21

these are the packages I am using in NixOS to build Godot Engine:

wayland.dev wayland-scanner wayland-utils libGLU libglvnd xorg.libX11 xorg.libXcursor xorg.libXrandr xorg.libXinerama xorg.libXi xorg.libXrandr mesa libexecinfo eudev alsa-lib pulseaudio python3 scons gcc pkg-config

It builds fine without any problem, only when I launch the godot binary, it shows the godot logo for moments then crashes

Screenshot from 2024-08-23 03-29-57

Then the crash: image

BTW, I can run the official 4.3 stable version fine on my system: image

also before going to this commit, I could previously compile and run Godot at some point in 4.3 commits. Edit: I mean this commit builds and runs fine: b7feebefabc2d48b0d4794cd31fc141f1caecc5c

System information

NixOS 24.05, CPU: AMD Ryzen 7 5800H with Radeon Graphics, GPU: NVIDIA GeForce RTX 3070 Mobile / Max-Q

Issue description

handle_crash: Program crashed with signal 11 Engine version: Godot Engine v4.4.dev.custom_build (568589c9d8c763bfb3a4348174d53b42d7c59f21) Dumping the backtrace. Please include this when reporting the bug to the project developer. [1] /lib64/libc.so.6(+0x3ff30) [0x7ff82612df30] (??:0) [2] ./bin/godot.linuxbsd.editor.x86_64() [0x1442c42] (??:0) [3] /lib64/libvulkan.so.1(+0x362e9) [0x7ff81e24a2e9] (??:0) [4] /lib64/libvulkan.so.1(vkEnumeratePhysicalDevices+0x8c) [0x7ff81e24f81c] (??:0) [5] ./bin/godot.linuxbsd.editor.x86_64() [0x144676a] (??:0) [6] ./bin/godot.linuxbsd.editor.x86_64() [0x1448230] (??:0) [7] ./bin/godot.linuxbsd.editor.x86_64() [0x3626206] (??:0) [8] ./bin/godot.linuxbsd.editor.x86_64() [0x1fcb413] (??:0) [9] ./bin/godot.linuxbsd.editor.x86_64() [0x18b760f] (??:0) [10] ./bin/godot.linuxbsd.editor.x86_64() [0x4f927f] (??:0) [11] ./bin/godot.linuxbsd.editor.x86_64() [0x424b49] (??:0) [12] /lib64/libc.so.6(+0x2a10e) [0x7ff82611810e] (??:0) [13] /lib64/libc.so.6(__libc_start_main+0x89) [0x7ff8261181c9] (??:0) [14] ./bin/godot.linuxbsd.editor.x86_64() [0x447a25] (??:0) -- END OF BACKTRACE --

Steps to reproduce

Build from source then run the godot binary

Minimal reproduction project (MRP)

N/A

Calinou commented 3 weeks ago

I get a similar 100% reproducible crash with self-compiled Godot as of 4.4.dev https://github.com/godotengine/godot/commit/568589c9d8c763bfb3a4348174d53b42d7c59f21:

handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.4.dev.custom_build (568589c9d8c763bfb3a4348174d53b42d7c59f21)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib64/libc.so.6(+0x40d00) [0x7f9b7f84fd00] (??:0)
[2] bin/godot.linuxbsd.editor.x86_64() [0x40e59eb] (/usr/include/c++/14/bits/atomic_base.h:641)
[3] bin/godot.linuxbsd.editor.x86_64() [0x40e5a7c] (/home/hugo/Documents/Git/godotengine/godot/drivers/vulkan/rendering_context_driver_vulkan.cpp:323)
[4] /lib64/libvulkan.so.1(+0x1b4f3) [0x7f9b6e2334f3] (??:0)
[5] /lib64/libvulkan.so.1(vkEnumeratePhysicalDevices+0x366) [0x7f9b6e24a886] (??:0)
[6] bin/godot.linuxbsd.editor.x86_64() [0x40e9562] (/home/hugo/Documents/Git/godotengine/godot/drivers/vulkan/rendering_context_driver_vulkan.cpp:820 (discriminator 1))
[7] bin/godot.linuxbsd.editor.x86_64() [0x40e9d56] (/home/hugo/Documents/Git/godotengine/godot/drivers/vulkan/rendering_context_driver_vulkan.cpp:918)
[8] bin/godot.linuxbsd.editor.x86_64() [0x2b58652] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/x11/display_server_x11.cpp:6171 (discriminator 1))
[9] bin/godot.linuxbsd.editor.x86_64() [0x2b54bf5] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/x11/display_server_x11.cpp:5430 (discriminator 1))
[10] bin/godot.linuxbsd.editor.x86_64() [0x78657d2] (/home/hugo/Documents/Git/godotengine/godot/servers/display_server.cpp:1199)
[11] bin/godot.linuxbsd.editor.x86_64() [0x2bfa188] (/home/hugo/Documents/Git/godotengine/godot/main/main.cpp:2839)
[12] bin/godot.linuxbsd.editor.x86_64() [0x2bf898f] (/home/hugo/Documents/Git/godotengine/godot/main/main.cpp:2556)
[13] bin/godot.linuxbsd.editor.x86_64() [0x2b187e5] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/godot_linuxbsd.cpp:74)
[14] /lib64/libc.so.6(+0x2a088) [0x7f9b7f839088] (??:0)
[15] /lib64/libc.so.6(__libc_start_main+0x8b) [0x7f9b7f83914b] (??:0)
[16] bin/godot.linuxbsd.editor.x86_64() [0x2b18625] (??:?)
-- END OF BACKTRACE --

--rendering-method gl_compatibility works in the meantime to force OpenGL, which works fine.

Edit: I bisected the regression to https://github.com/godotengine/godot/pull/90993. cc @darksylinc

PC specifications - **CPU:** Intel Core i9-13900K - **GPU:** NVIDIA GeForce RTX 4090 (NVIDIA 555.58.02) - **RAM:** 64 GB (2×32 GB DDR5-5800 C30) - **SSD:** Solidigm P44 Pro 2 TB - **OS:** Linux (Fedora 40)
ywmaa commented 3 weeks ago

changed the title, since it turned out not relating to NixOS

ywmaa commented 3 weeks ago

--rendering-method gl_compatibility works in the meantime to force OpenGL, which works fine.

for some reason it crashes on my end too!

Calinou commented 3 weeks ago

for some reason it crashes on my end too!

What do you get in the terminal when it crashes?

ywmaa commented 3 weeks ago

What do you get in the terminal when it crashes?

The exact same backtrace for vulkan!

I am sure that I am using the --rendering-method gl_compatibility command.

darksylinc commented 3 weeks ago

I assume you all compiled Godot 4.4 with dev_mode=True and/or dev_build=True ?

Because #90993 should not affect the build if both dev_mode=False and dev_build=False

It would also seem the common denominator so far are NVIDIA GPUs on Linux.

darksylinc commented 3 weeks ago

Does it get fixed if you apply #95975 on top of it?

ywmaa commented 3 weeks ago

both dev_mode=False and dev_build=False

should I pass to scons like this?

scons platform=linuxbsd dev_mode=False dev_build=False

darksylinc commented 3 weeks ago

They're disabled by default, so basically I was asking if you were compiling with:

scons platform=linuxbsd dev_mode=True dev_build=True

If you compile with

scons platform=linuxbsd

Then it's the same as setting both of them to False

ywmaa commented 3 weeks ago

Then it's the same as setting both of them to False

Then I always compiled with them set to false, I only compile with the command

scons platform=linuxbsd
darksylinc commented 3 weeks ago

Holy s**t. Something went terribly wrong then.

Thanks! I'm testing this ASAP.

darksylinc commented 3 weeks ago

I cannot reproduce it on my two machines:

Both machines use Ubuntu 20.04.04 LTS.

This could still be an NV issue that only manifests on newer GPUs.

This may be a Vulkan Loader issue (basically the system that loads the actual Vulkan driver; and on Linux it is provided by the distro).

Personally I've tested loader versions 1.2.131.2-1 (the one provided by Ubuntu 20.04) and loader 1.3.261.1 (one I installed by hand).

You can test the Loader theory by installing one by hand:

  1. Download Vulkan SDK from its homepage https://vulkan.lunarg.com/sdk/home#linux
  2. Extract it somwhere, e.g. /home/username/vulkan
  3. Launch Godot with the following environment variables:
export LD_LIBRARY_PATH=/home/username/vulkan/1.3.261.1/x86_64/lib
export PATH=/home/username/.local/share/mold/bin:/home/username/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/username/.dotnet/tools:/home/username/vulkan/1.3.261.1/x86_64/bin
export VK_LAYER_PATH=/home/username/vulkan/1.3.261.1/x86_64/etc/vulkan/explicit_layer.d
export VULKAN_SDK=/home/username/vulkan/1.3.261.1/x86_64
./godot.linuxbsd.editor.x86_64 -e

But I've got a better understanding now: The Editor build sets DEBUG_ENABLED flag, which includes the extra code that is causing the crash.

I'm not sure if the code from #90993 intended for it to be enabled in the Editor.

A simple hotfix right now since users are crashing is to find the following in rendering_context_driver_vulkan.h:

#if defined(DEBUG_ENABLED) || defined(DEV_ENABLED)
#define VK_TRACK_DRIVER_MEMORY
#define VK_TRACK_DEVICE_MEMORY
#endif

and change it to:

#if defined(DEV_ENABLED)
#define VK_TRACK_DRIVER_MEMORY
#define VK_TRACK_DEVICE_MEMORY
#endif

Then rebuild. That should fix the crash.

Though I'd want to chat with @Calinou to see if we can debug the issue on his machine since he can reproduce it.

Update: May I ask the output when launched with --verbose ?

ywmaa commented 2 weeks ago

Verbose log

Godot Engine v4.4.dev.custom_build.1f957a05a (2024-08-23 00:06:43 UTC) - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
JoypadLinux: udev enabled and loaded successfully.
ERROR: Can't connect to a Wayland display.
   at: init (platform/linuxbsd/wayland/wayland_thread.cpp:3690)
ERROR: Could not initialize the Wayland thread.
   at: DisplayServerWayland (platform/linuxbsd/wayland/display_server_wayland.cpp:1337)
ERROR: Can't create the Wayland display server.
   at: create_func (platform/linuxbsd/wayland/display_server_wayland.cpp:1311)
Xshape 1.1 detected.
Xinerama 1.1 detected.
Xrandr 1.6 detected.
Xrender 0.11 detected.
Xinput 2.2 detected.
XInput: Refreshing devices.
XInput: No touch devices found.
Custom libGL override detected. Skipping GPU detection
Custom libGL override detected. Skipping GPU detection
Custom libGL override detected. Skipping GPU detection
Failed loading custom cursor: crossed_circle
ScreenSaver: DBus 1.14.10 detected.
FreeDesktopScreenSaver: Acquired screensaver inhibition cookie: 1508944488
PortalDesktop: DBus 1.14.10 detected.
Using "default" pen tablet driver...
Shader 'CanvasSdfShaderGLES3' SHA256: 0a8d8e3bca87ef0b7d3d5c372ef3d60638cacee9eb0986c078eeb63e36a90ce9
Shader 'SkeletonShaderGLES3' SHA256: 1c97abeb6b88afeaf3256ffeb88f030729822ab2d7ef02d6278be36059bf7278
Shader 'ParticlesShaderGLES3' SHA256: 85295341556eae502bc54e759abfde640d9a5155519ca00e43a41c7cb040496c
Shader 'ParticlesCopyShaderGLES3' SHA256: 2deb4c4a59bd27e018f551c981e6ca284adaeadb4b4bcd749498f834cbe30ac9
Shader 'CopyShaderGLES3' SHA256: c40e5967316787b5cbe74baac5f0c02380166c927e08fb35419b2197b323af75
Shader 'CubemapFilterShaderGLES3' SHA256: a2912b8c077a39033c01e321286d5b3a4440fe3119d93e7f9bd3267d44806361
Shader 'GlowShaderGLES3' SHA256: 18b01df0fe0d94c6ef8b9140360a2f61b9db819a50efa35326a61ec4f6253d47
Shader 'PostShaderGLES3' SHA256: 6bb6492602c7eed84915f9a7ebd8ee4d1c6b5beb1ccde524ff0282bbc6951b4e
Shader 'CanvasShaderGLES3' SHA256: d88dc239653cbe580776bc2c0484b15fea657f53c9edc5f2b5d3b70809a1ae8b
Shader 'CanvasOcclusionShaderGLES3' SHA256: dd1ebcba3bb83de418c6434207c47a34c6893c270cb43f2df5912db6b270622a
Shader 'SceneShaderGLES3' SHA256: 701b5427aca902a83f36c34ae9e166a240b1ffcd77607785c8f03f13e03a194a
Shader 'SkyShaderGLES3' SHA256: 6e108d32b9b943ec83763cedf4b791022e1149f6f845bcf06d25b0c56dc6249d
OpenGL API 4.6 (Core Profile) Mesa 24.0.7 - Compatibility - Using Device: AMD - AMD Radeon Graphics (radeonsi, renoir, LLVM 17.0.6, DRM 3.57, 6.9.11)
PulseAudio 17.0.0 detected.
PulseAudio: context other
PulseAudio: context other
PulseAudio: context other
PulseAudio: context ready
PulseAudio: Detecting channels for device: alsa_output.pci-0000_05_00.6.analog-stereo
PulseAudio: detected 2 output channels
PulseAudio: audio buffer frames: 512 calculated output latency: 11ms

TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
CORE API HASH: 3992730498
EDITOR API HASH: 1287218416
EditorSettings: Load OK!
EditorTheme: Generating new theme for the config '4149511488'.
EditorTheme: Generating new icons.
EditorTheme: Generating new fonts.
EditorTheme: Generating new styles.
ERROR: Cannot open file '/home/ywmaa/Documents/editor_theme.tres'.
   at: load (scene/resources/resource_format_text.cpp:1367)
ERROR: Failed loading resource: /home/ywmaa/Documents/editor_theme.tres. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:287)
WARNING: GENERAL - Message Id Number: 0 | Message Id Name: Loader Message
        terminator_CreateInstance: Received return code -3 from call to vkCreateInstance in ICD /nix/store/raj03q8wil10103d050d0ngx4k0qfjyc-mesa-24.0.7-drivers/lib/libvulkan_dzn.so. Skipping this driver.
        Objects - 1
                Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 249223200
     at: _debug_messenger_callback (drivers/vulkan/rendering_context_driver_vulkan.cpp:624)
WARNING: GENERAL - Message Id Number: 0 | Message Id Name: Loader Message
        terminator_CreateInstance: Received return code -3 from call to vkCreateInstance in ICD /nix/store/raj03q8wil10103d050d0ngx4k0qfjyc-mesa-24.0.7-drivers/lib/libvulkan_virtio.so. Skipping this driver.
        Objects - 1
                Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 249223200
     at: _debug_messenger_callback (drivers/vulkan/rendering_context_driver_vulkan.cpp:624)
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
ERROR: GENERAL - Message Id Number: 0 | Message Id Name: ../src/nouveau/vulkan/nvk_physical_device.c:935
        VK_ERROR_INCOMPATIBLE_DRIVER
        Objects - 1
                Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 224245312
   at: _debug_messenger_callback (drivers/vulkan/rendering_context_driver_vulkan.cpp:627)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.4.dev.custom_build (1f957a05aff5ee9247aa736a413abd6549b48cc6)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib64/libc.so.6(+0x3ff30) [0x7fc536e95f30] (??:0)
[2] ./bin/godot.linuxbsd.editor.x86_64() [0x1442c42] (??:0)
[3] /lib64/libvulkan.so.1(+0x362e9) [0x7fc52f04a2e9] (??:0)
[4] /lib64/libvulkan.so.1(vkEnumeratePhysicalDevices+0x8c) [0x7fc52f04f81c] (??:0)
[5] ./bin/godot.linuxbsd.editor.x86_64() [0x144676a] (??:0)
[6] ./bin/godot.linuxbsd.editor.x86_64() [0x1448230] (??:0)
[7] ./bin/godot.linuxbsd.editor.x86_64() [0x36264b6] (??:0)
[8] ./bin/godot.linuxbsd.editor.x86_64() [0x1fcb633] (??:0)
[9] ./bin/godot.linuxbsd.editor.x86_64() [0x18b782f] (??:0)
[10] ./bin/godot.linuxbsd.editor.x86_64() [0x4f927f] (??:0)
[11] ./bin/godot.linuxbsd.editor.x86_64() [0x424b49] (??:0)
[12] /lib64/libc.so.6(+0x2a10e) [0x7fc536e8010e] (??:0)
[13] /lib64/libc.so.6(__libc_start_main+0x89) [0x7fc536e801c9] (??:0)
[14] ./bin/godot.linuxbsd.editor.x86_64() [0x447a25] (??:0)
-- END OF BACKTRACE --
================================================================
ywmaa commented 2 weeks ago

A simple hotfix right now since users are crashing is to find the following in rendering_context_driver_vulkan.h:

This works!

ywmaa commented 2 weeks ago

This may be a Vulkan Loader issue (basically the system that loads the actual Vulkan driver; and on Linux it is provided by the distro).

just custom installed vulkan-1.3.290.0, exported the variable and with the code as is without the hotfix, and it works too

also I don't have the vulkan sdk installed on my system, so perhaps that's why it crashes since it can't find the vulkan sdk for debugging.

darksylinc commented 2 weeks ago

Ok that actually answers all the questions! It must be a Loader bug in the loader bundled by the distro. Thanks for the info!

It seems like we'll have to disable the functionality from user-facing Editor builds.