smcameron / space-nerds-in-space

Multi-player spaceship bridge simulator game. Captain your starship through adventures with your friends. See https://smcameron.github.io/space-nerds-in-space
GNU General Public License v2.0
724 stars 73 forks source link

Segfault when running snis_client #301

Closed koepnick closed 2 years ago

koepnick commented 2 years ago

Version: git main branch

Distribution: Arch

Linux XYZLinux 5.13.12-arch1-1 #1 SMP PREEMPT Wed, 18 Aug 2021 20:49:03 +0000 x86_64 GNU/Linux

gcc: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.1.0 (GCC)

Window Manager: SwayWM (running under wlroots)

Error message:
Thread 1 "snis_client" received signal SIGSEGV, Segmentation fault. 0x00007ffff77dc738 in __memmove_avx_unaligned_erms () from /usr/lib/libc.so.6

Backtrace: (gdb) bt

0 0x00007ffff77dc738 in __memmove_avx_unaligned_erms () from /usr/lib/libc.so.6

1 0x00007fffee8a2cf2 in ?? () from /usr/lib/dri/iris_dri.so

2 0x00007fffef392e37 in ?? () from /usr/lib/dri/iris_dri.so

3 0x00007fffee4d060a in ?? () from /usr/lib/dri/iris_dri.so

4 0x00005555555c10a5 in draw_vertex_buffer_2d.part ()

5 0x00005555555c34e7 in graph_dev_draw_entity ()

6 0x00005555555aac0f in render_entities ()

7 0x00005555555cf3a5 in show_rotating_wombat ()

8 0x0000555555609b7e in main_da_expose ()

9 0x000055555557866c in main ()

quit)

Thoughts: Using Nouveau driver for the internal GPU and Intel Corporation CometLake-H GT2 [UHD Graphics] for the integrated.

smcameron commented 2 years ago

Anything in snis_client_log.txt ?

smcameron commented 2 years ago

Also, long shot, probably not the same, but I found this: https://bugs.launchpad.net/ubuntu/+source/mesa/+bug/1877879

"As of Ubuntu 20.04, on intel graphics with intel driver (not modesetting), I got segfault whenever anything tries to use GL.

This happens unless I export MESA_LOADER_DRIVER_OVERRIDE=i965. One says that it does not happen with modesetting driver."

So maybe try "export MESA_LOADER_DRIVER_OVERRIDE=i965" ?

koepnick commented 2 years ago

Same issue, though the backtrace is now referencing the i965 drivers so at least we know that the env variable is being honored.

gdb) bt
#0  0x00007ffff77dc5bb in __memmove_avx_unaligned_erms () from /usr/lib/libc.so.6
#1  0x00007fffeee3004f in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007fffeee358ba in ?? () from /usr/lib/dri/i965_dri.so
#3  0x00007fffef31d626 in ?? () from /usr/lib/dri/i965_dri.so
#4  0x00007fffeee3e559 in ?? () from /usr/lib/dri/i965_dri.so
#5  0x00007fffeee3fb72 in ?? () from /usr/lib/dri/i965_dri.so
#6  0x00007fffeee41341 in ?? () from /usr/lib/dri/i965_dri.so
#7  0x00007fffeefb4160 in ?? () from /usr/lib/dri/i965_dri.so
#8  0x00007fffeefae77a in ?? () from /usr/lib/dri/i965_dri.so
#9  0x00005555555c10a5 in draw_vertex_buffer_2d.part ()
#10 0x00005555555c34e7 in graph_dev_draw_entity ()
#11 0x00005555555aac0f in render_entities ()
#12 0x00005555555cf3a5 in show_rotating_wombat ()
#13 0x0000555555609b7e in main_da_expose ()
#14 0x000055555557866c in main ()
smcameron commented 2 years ago

Very mysterious. Anything in snis_client_log.txt ?

smcameron commented 2 years ago

So, this feels like either a driver bug (in which case we're probably hosed), or perhaps my program is doing something wrong which drivers that I've seen up to now have been erroneously allowing me to get away with. In the latter case, we have some hope. Here's a patch which might help to narrow down what I might be doing wrong, if in fact I'm doing something wrong. Give it a try when you get a chance, and hopefully there will be some clues in snis_client_log.txt.

debug-draw-vertex-buffer-2d.txt

koepnick commented 2 years ago
cat snis_client_log.txt
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Portaudio reports 15 sound devices.
Portaudio says the default device is: 13
Portaudio reports 15 devices
0: HDA Intel PCH: ALC289 Analog (hw:0,0)
1: HDA Intel PCH: HDMI 0 (hw:0,3)
2: HDA Intel PCH: HDMI 1 (hw:0,7)
3: HDA Intel PCH: HDMI 2 (hw:0,8)
4: HDA Intel PCH: HDMI 3 (hw:0,9)
5: HDA Intel PCH: HDMI 4 (hw:0,10)
6: sysdefault
7: front
8: surround40
9: surround51
10: surround71
11: hdmi
12: pipewire
13: default
14: dmix
Decoding audio data...Done.
Reading solarsystem specifications...done
Reading starbase model specifications...done
We got a problem keysym is 1073742049
We got a problem keysym is 1073742053
Apparently not X11, no aspect ratio constraining for you!
Failed to initialize GLEW
Re-loading per solarsystem textures
load_per_solarsystem_textures, loading
xdg_surface@29: error -1: Tried to set invalid xdg-surface geometry
malloc_consolidate(): unaligned fastbin chunk detected

I'll apply the patch when I get home later tonight. I also have another, more stable system there (Mint). It may be that I'm too much on the cutting edge on my laptop.

kwadroke commented 2 years ago
Apparently not X11, no aspect ratio constraining for you!
Failed to initialize GLEW

Are you using Wayland perhaps? Probably will have to run Xorg.

koepnick commented 2 years ago

A little bit of tinkering and it seems to be working.

Installed an AUR package of glew with support for EGL. It's running like a dream.

Thank you, everybody for your time and help!

smcameron commented 2 years ago

Cool!

Wrongtown commented 2 years ago
Apparently not X11, no aspect ratio constraining for you!

I just want to take a moment to appreciate this log message, love it.

smcameron commented 2 years ago
Apparently not X11, no aspect ratio constraining for you!

I just want to take a moment to appreciate this log message, love it.

If someone knows how to implement aspect ratio constraints in Wayland, the place to do it is here:

https://github.com/smcameron/space-nerds-in-space/blob/master/snis_xwindows_hacks.c#L50

although some renaming of things would be in order. snis_xwindows_hacks -> snis_window_manager_hacks, etc.

smcameron commented 2 years ago

BTW, speaking of Wayland and aspect ratios, I think I may have figured out a way to do aspect ratio constraining for window managers that don't or won't do it for you, see: https://github.com/smcameron/space-nerds-in-space/issues/302

I haven't tested my fix on Wayland because I don't have any systems running Wayland. I have tested on X11 (disabling the native X11 way of constraining the aspect ratio first) and it seems to work. Or works about 90%, that is, you can drag the window to sizes that do not conform to the aspect ratio, but as soon as you release the mouse button it snaps to the correct size. Since at least one person in this thread is running Wayland, maybe one of you could test that out for me (just resize the snis_client window and make sure it maintains the correct aspect ratio.)