Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instant segfault after building on Linux #769

Open
brosasaki opened this issue Jan 27, 2025 · 9 comments
Open

Instant segfault after building on Linux #769

brosasaki opened this issue Jan 27, 2025 · 9 comments
Assignees
Labels

Comments

@brosasaki
Copy link

LOW EFFORT BUG REPORTS WILL BE CLOSED

Describe the bug
While packaging the latest release for Guix, I ran into an issue where when compiling and running vkquake, the program instantly segfaults as it loads the first demo.

To Reproduce

  1. Install/update guix (as a system, or over your current system)
  2. download the attached file vkquake.txt
  3. Run 'guix build --file=/path/to/vkquake.txt'. This should succeed.
  4. Go to the outputted path and run bin/vkquake with your quake files.
  5. Observe the near-instant segfault.

Expected behavior
Quake loads up and displays the first demo without issue.

Screenshots
No screenshots, but I do have the program output:

Command line: /gnu/store/xn65dvzs9llf87g4wsahnzzf93zbr8qp-vkquake-1.32.0/bin/vkquake -basedir /home/wong/downloads/quake/
Found SDL version 2.30.8
Detected 16 CPUs.
Initializing vkQuake 1.32.0
Built with GCC 11.4.0
Host_Init
Playing registered version.
Console initialized.
UDP4 Initialized
UDPv6 Initialized
Server using protocol 999+ (FTE-RMQ)
Exe: 00:00:01 Jan  1 1970

Vulkan Initialization
Using Vulkan 1.1
Instance extensions:
 VK_KHR_surface
 VK_KHR_wayland_surface
 VK_KHR_get_surface_capabilities2
 VK_KHR_get_physical_device_properties2
 VK_EXT_debug_utils

Vendor: AMD
Device: AMD Radeon RX 7900 XTX (RADV NAVI31)
Driver: radv Mesa 24.3.2
Using subgroup operations
Using ray queries
Device extensions:
 VK_KHR_swapchain
 VK_KHR_get_memory_requirements2
 VK_KHR_dedicated_allocation
 VK_EXT_subgroup_size_control
 VK_KHR_acceleration_structure
 VK_EXT_descriptor_indexing
 VK_KHR_buffer_device_address
 VK_KHR_deferred_host_operations
 VK_KHR_shader_float_controls
 VK_KHR_spirv_1_4
 VK_KHR_acceleration_structure
 VK_KHR_ray_query
Using A2B10G10R10 color buffer format
Using D32_S8 depth buffer format

Creating command buffers
Initializing staging
Creating descriptor set layouts
Reallocating dynamic vertex buffers (256 KB)
Reallocating dynamic index buffers (1024 KB)
Reallocating dynamic uniform buffers (256 KB)
Initializing samplers
Texture lod bias: 0.000000
Creating pipeline layouts
DEBUG: Using udev for HIDAPI joystick device discovery
DEBUG: Failed loading udev_device_get_action: /gnu/store/ysb32k2n2gw76adprya0c6anl0z9a5ry-sdl2-2.30.8/lib/libSDL2-2.0.so.0: undefined symbol: _udev_device_get_action
DEBUG: Using udev for joystick device discovery
DEBUG: Couldn't open /home/wong/downloads/quake/gamecontrollerdb.txt: No such file or directory
DEBUG: Invalid RWops
Allocating lightstyles buffer (0 KB)
Allocating lights buffer (8 KB)

Sound Initialization
Using FIFO present mode
Creating color buffer
4 AA Samples
Supersampling enabled
Creating depth buffer
Creating render passes
Creating frame buffers
Creating pipelines
DEBUG: setpriority() failed
SDL audio spec  : 44100 Hz, 1024 samples, 2 channels
SDL audio driver: pulseaudio - Bose QC Ultra Headphones, 65536 bytes buffer
Audio: 16 bit, stereo, 44100 Hz

Language initialization
DEBUG: Couldn't open /home/wong/downloads/quake/localization/loc_english.txt: No such file or directory
DEBUG: Couldn't open /home/wong/downloads/quake/QuakeEX.kpf: No such file or directory
Couldn't load 'localization/loc_english.txt'
from '/home/wong/downloads/quake'

========= Quake Initialized =========

execing quake.rc
Using FIFO present mode
Creating color buffer
4 AA Samples
Supersampling enabled
Creating depth buffer
Creating render passes
Creating frame buffers
Creating pipelines
Initializing samplers
Texture lod bias: -1.000000
execing default.cfg
execing config.cfg
Unknown command "gl_subdivide_size"
Unknown command "gl_triplebuffer"
Unknown command "joy_deadzone"
Unknown command "r_shadows"
Unknown command "sys_throttle"
Unknown command "vid_bpp"
Initializing samplers
Texture lod bias: -1.000000
couldn't exec autoexec.cfg
3 demo(s) in loop
Playing demo from demo1.dem.

����������������������������������������

the Necropolis
Using protocol 15
Allocating lightmap compute surface data (332 KB)
Allocating acceleration structure data (4999 KB)
Allocating indirect draw data (1 KB, 72 draws)
Allocating indirect IBs (170 KB)
Allocating visibility buffers (1 KB)
Segmentation fault

Desktop (please complete the following information):

  • OS: Linux
  • GPU: AMD Radeon RX 7900 XTX (RADV NAVI31)
  • Driver: radv Mesa 24.3.2

Mod
No mods.

Additional context
There's a good chance this issue is caused by the compilation environment, and also a good change that it's caused by some assumption in the compilation process. Though it would help if someone else tried compiling on guix themselves, it would also help alot even if someone more familiar with the code could interpret the debug/error messages. I see the errors, I just don't know what they really mean.

@j4reporting
Copy link
Contributor

Do you have a backtrace of the crash, preferably with a debug binary ( maybe coredumpctl info, see coredumpctl list for available coredumps )?

Can you reproduce the crash with vkquake -nosound or vkquake +cl_startdemos 0 and then start a new game with map start?
I think the guix build binary does not support mp3, but this should not cause a crash.

In the guix configure file change libmad to mpg123 or libmpg123 or call meson with the option -Dmp3_lib=mad
see

option('mp3_lib', type : 'combo', value : 'mpg123', choices: ['mad', 'mpg123'])

@brosasaki
Copy link
Author

Here's a backtrace:

(gdb) bt
#0  0x00007f53378f3a6d in ?? () from /gnu/store/vnl013p4jbvq1p964gkydyd99s2ijhzm-mesa-24.3.2/lib/libvulkan_radeon.so
#1  0x000000000044b0be in GL_UpdateDescriptorSets () at ../source/Quake/gl_vidsdl.c:1953
#2  0x000000000044b0e5 in GL_UpdateDescriptorSets () at ../source/Quake/gl_vidsdl.c:1956
#3  0x000000000043852e in R_NewMap () at ../source/Quake/gl_rmisc.c:3876
#4  0x000000000040e7a6 in CL_ParseServerInfo () at ../source/Quake/cl_parse.c:1040
#5  0x000000000041104e in CL_ParseServerMessage () at ../source/Quake/cl_parse.c:1840
#6  0x000000000040de59 in CL_ReadFromServer () at ../source/Quake/cl_main.c:950
#7  0x00000000004506ad in _Host_Frame (time=time@entry=0.016056615975685418) at ../source/Quake/host.c:957
#8  0x0000000000450b19 in Host_Frame (time=time@entry=0.016056615975685418) at ../source/Quake/host.c:1003
#9  0x0000000000407444 in main (argc=<optimized out>, argv=<optimized out>) at ../source/Quake/main_sdl.c:122

note: I'm not sure how to "load" in the debug symbols for libvulkan_radeon.so, help would be appreciated if it's necessary.

I've found that -nosound has no effect, but +cl_startdemos 0 avoids the crash until an attempt is made to start a new game.

Building with mpg123 instead of libmad has no effect.

@j4reporting
Copy link
Contributor

this looks like a bug in the radeon driver. I can´t reproduce with Intel TigerLake-LP GT2 ( i7-1165G7 ) (mesa 23.3.4 / mesa 23.3.2 ) and with the nouveau Nvidia driver ( TU106M ) (Mesa 23.3.2 ).

I don´t have an AMD GPU with Vulkan support available for testing.

Mesa 23.3.2 and 23.3.3 seems to have some issues, any chance to try with Mesa 23.3.1 or 23.2.8?
Mesa 23.3.4 has been released recently as well.

Flatpak has also not yet updated mesa to a newer version than 23.3.1.

Freedesktop Platform         org.freedesktop.Platform                      freedesktop-sdk-23.08.27    23.08          system
Freedesktop Platform         org.freedesktop.Platform                      freedesktop-sdk-24.08.10    24.08          system
Mesa                         org.freedesktop.Platform.GL.default           24.3.1                      23.08          system
Mesa (Extra)                 org.freedesktop.Platform.GL.default           24.3.1                      23.08-extra    system
Mesa                         org.freedesktop.Platform.GL.default           24.3.1                      24.08          system
Mesa (Extra)                 org.freedesktop.Platform.GL.default           24.3.1                      24.08extra     system

@j4reporting
Copy link
Contributor

You can test the compiled binary with mesa's software renderer llvmpipe like this:
fedora41: VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json <path>/vkquake <options>

you need to locate the json file on your system first.

Vulkan Initialization
Using Vulkan 1.1
Instance extensions:
 VK_KHR_surface
 VK_KHR_wayland_surface
 VK_KHR_get_surface_capabilities2
 VK_KHR_get_physical_device_properties2

Vendor: MESA
Device: llvmpipe (LLVM 19.1.5, 256 bits)
Driver: llvmpipe Mesa 24.3.4 (LLVM 19.1.5)
Using subgroup operations
Using ray queries
Device extensions:
 VK_KHR_swapchain
 VK_KHR_get_memory_requirements2
 VK_KHR_dedicated_allocation
 VK_EXT_subgroup_size_control
 VK_KHR_acceleration_structure
 VK_EXT_descriptor_indexing
 VK_KHR_buffer_device_address
 VK_KHR_deferred_host_operations
 VK_KHR_shader_float_controls
 VK_KHR_spirv_1_4
 VK_KHR_acceleration_structure
 VK_KHR_ray_query
Using A2B10G10R10 color buffer format
Using D32_S8 depth buffer format
3 demo(s) in loop
Playing demo from demo1.dem.



the Necropolis
Using protocol 15
Allocating lightmap compute surface data (332 KB)
Allocating indirect draw data (1 KB, 72 draws)
Allocating indirect IBs (170 KB)
Allocating visibility buffers (1 KB)
You got the shells
You got the Grenade Launcher
]disconnect 

@brosasaki
Copy link
Author

I was able to get the game to start using lvp_icd.x86_64.json from mesa 24.0.4, but not 24.2.5 or 24.3.2 (the latest one on guix), which crash with the same stack trace (save the change from radeon to lvp). Moreover, using radeon_icd.x86_64.json from 24.0.4, 24.2.5, and 24.3.2 also crash the same way. Is it possible vkquake runs on some undocumented/not fully implemented behavior?

version lvp radeon
24.0.4 RUNS CRASH
24.2.5 CRASH CRASH
24.3.2 CRASH CRASH

@j4reporting
Copy link
Contributor

That's very odd. Does the appimage https://github.com/Novum/vkQuake/releases/tag/1.32.0 also crash with lvp?

@brosasaki
Copy link
Author

Unfortunately I was unable to get the appimage to run:

vkquake-ea6d5eb8_linux64 🮲🮳 guix shell zlib --container --emulate-fhs --expose=$HOME/downloads/quake -- squashfs-root/AppRun -basedir ~/downloads/quake
Command line: squashfs-root/AppRun -basedir /home/wong/downloads/quake
Found SDL version 2.30.11
Detected 16 CPUs.
Initializing vkQuake 1.32.0
Built with GCC 9.4.0
Host_Init
Playing registered version.
Console initialized.
UDP4 Initialized
UDPv6 Initialized
Server using protocol 999+ (FTE-RMQ)
Exe: 09:02:27 Jan 12 2025

ERROR-OUT BEGIN


QUAKE ERROR: Couldn't create window: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform

@j4reporting
Copy link
Contributor

j4reporting commented Jan 29, 2025

libvulkan is packaged in the AppImage. Maybe it was not able to find your mesa libs?

It's possible to extract the content with --appimage-extract or mount with --appimage-mount and ls, cp
Extract the content, then rename or move the libs in usr/lib to another location, so that the binary can't find them automatically. Check with ldd usr/bin/vkquake. Let's start by moving/renaming libSDL2 and libvulkan only. We don't have issues with sound.
All you need to do is to check with ldd if vkquake is able to find your system's libsdl2 and libvulkan, either in the default locations like /lib64 or /usr/lib64 or something guix is doing.
LD_LIBRARY_PATH could help.

the binary's default search path for libs is

readelf -d squashfs-root/usr/bin/vkquake   |grep runpath
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib]

so you need to first cd to squashfs-root/usr/bin or set LD_LIBRARY_PATH to /squashfs-root/usr/lib/

This binary does work here with Mesa 24.3.2 lvp!

I suspect that your Mesa versions are buggy, perhaps compiled with to aggressive compiler otimizations.
It's strange that 24.0.4 worked and newer versions did not. Does guix have a central repository or did you compile the mesa packages on your system? Is the CPU overclocked?

here is a binary compiled on ubuntu22.04 with only sound for WAV enabled. This binary does work witk mesa's lvp on Fedora41

meson setup build_nosound -Duse_codec_mp3=disabled -Duse_codec_flac=disabled -Duse_codec_vorbis=disabled -Duse_codec_opus=disabled -Dbuildtype=debug

required libraries are:


readelf -d vkquake |grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libSDL2-2.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libvulkan.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

ldconfig (Ubuntu GLIBC 2.35-0ubuntu3.8) 2.35

vkquake_ubuntu22.04.tar.gz

@brosasaki
Copy link
Author

All you need to do is to check with ldd if vkquake is able to find your system's libsdl2 and libvulkan, either in the default locations like /lib64 or /usr/lib64 or something guix is doing.

So, I was able to get the executable you sent to "find" my system's libraries(according to ldd), but I still get the same error :(.

Does guix have a central repository or did you compile the mesa packages on your system? Is the CPU overclocked?

Guix uses a central repository to compile binary packages it calls "substitutes", falling back to locally-compiled packages which should match, bit-for-bit. Therefore, if a library is buggy for one package, it should be buggy for other packages, too, maybe? Here's guix' package definition for mesa, and for sdl2, maybe the flags, etc. used to compile them matter here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants