libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
191 stars 40 forks source link

Steel Storm Burning Retribution demo: can crash with BadWindow, workaround: SDL12COMPAT_ALLOW_SYSWM=0 #290

Closed smcv closed 1 year ago

smcv commented 1 year ago

To reproduce:

Expected result: all runs succeed

Actual result:

ERROR: ld.so: object '/home/desktop/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Game is Steel-Storm using base gamedir gamedata
Steel-Storm Linux 17:34:16 Jun 25 2013 11958M release
Current nice level is below the soft limit - cannot use niceness
Playing shareware version.
Skeletal animation uses SSE code path
DPSOFTRAST available (SSE2 instructions detected)
Failed to init SDL joystick subsystem: Failed loading udev_device_get_action: /home/desktop/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so: undefined symbol: _udev_device_get_action
execing quake.rc
execing default.cfg
execing config.cfg
couldn't exec autoexec.cfg
Client using an automatically assigned port
Client opened a socket on address 0.0.0.0:0
Linked against SDL version 1.2.14
Using SDL library version 1.2.62
This XPM's palette is either huge or idiotically unoptimized. It's key size is 2
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: NVIDIA GeForce GTX 1080/PCIe/SSE2
GL_VERSION: 4.6.0 NVIDIA 510.108.03
vid.support.arb_multisample 1
vid.support.gl20shaders 1
NOTE: requested 1x AA, got 0x AA
Video Mode: fullscreen 1920x1080x32x0.00hz
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  18 (X_ChangeProperty)
  Resource id in failed request:  0x0
  Serial number of failed request:  353
  Current serial number in output stream:  354
smcv commented 1 year ago

This appears to be a game based on darkplaces (modified Quake).

The same versions work well on a different test machine with: Debian 12 prerelease, AMD vega10, Mesa; and either GNOME (Wayland) or Xfce (Xorg). At this stage I'm unsure whether it's Ubuntu vs Debian or NVIDIA vs AMD/Mesa that is significant.

smcv commented 1 year ago

For an apples-to-apples comparison, I booted both test machines into Debian 11 stable with GNOME (Xorg) and the same game works fine there; so this might be Ubuntu-specific or NVIDIA-driver-version-specific.

I won't be able to test Ubuntu 22.04 on AMD or Debian 12 on NVIDIA until I've installed the relevant operating systems, which will take a while.

sulix commented 1 year ago

So, interestingly, I couldn't reproduce this (with the full game, not the demo) just running the game through Steam (both with and without the pressure-vessel 'Steam Linux Runtime') on openSUSE Tumbleweed with nVidia/KDE/Wayland.

However, if I ran the game directly (instead of via Steam), I get the same BadWindow error.

It looks like the game is trying to set a window icon, and is passing NULL as the Window:

(gdb) bt
#0  XChangeProperty (dpy=0x2894c30, w=0, property=331, type=6, format=32, mode=0, data=0x797c00 "", nelements=65538) at /usr/src/debug/libX11-1.8.4/src/ChProp.c:42
#1  0x0000000000404441 in ?? ()
#2  0x0000000000408202 in ?? ()
#3  0x0000000000678135 in ?? ()
#4  0x000000000067be17 in ?? ()
#5  0x0000000000543b7b in ?? ()
#6  0x000000000047948d in ?? ()
#7  0x0000000000541267 in ?? ()
#8  0x0000000000542b63 in ?? ()
#9  0x0000000000404053 in ?? ()
#10 0x00007ffff7b3cbb0 in __libc_start_call_main (main=main@entry=0x403fe0, argc=argc@entry=1, argv=argv@entry=0x7fffffffd838) at ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x00007ffff7b3cc79 in __libc_start_main_impl (main=0x403fe0, argc=1, argv=0x7fffffffd838, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd828)
    at ../csu/libc-start.c:360
#12 0x0000000000403c59 in ?? ()
#13 0x00007fffffffd828 in ?? ()
#14 0x0000000000000038 in ?? ()
#15 0x0000000000000001 in ?? ()
#16 0x00007fffffffdd40 in ?? ()
#17 0x0000000000000000 in ?? ()
(gdb) call XGetAtomName((Display*)0x2894c30, 331)
$1 = 0x30ad9d0 "_NET_WM_ICON"

Using either SDL12COMPAT_ALLOW_SYSWM=0 or forcing the game to use wayland with SDL_VIDEODRIVER=wayland both fixed it.

smcv commented 1 year ago

both with and without the pressure-vessel 'Steam Linux Runtime'

FYI, I wasn't using the container/pressure-vessel "Steam Linux Runtime" for this testing, only the legacy LD_LIBRARY_PATH-based runtime. Currently the container runtime is the default on Steam Deck, and the legacy LD_LIBRARY_PATH-based runtime is the default everywhere else.

sulix commented 1 year ago

I think openSUSE does some nasty patching to force Steam to use the distro versions of some libraries, rather than the Steam Runtime versions, so that might explain some of the differences.

/proc/pid/maps definitely gives the distro version of sdl12-compat by default when launching through Steam, and it's exactly the same library running when I get BadWindow locally. Swapping out a self-compiled sdl12-compat doesn't change anything.

(There are a bunch of other libraries which come from the steam runtime when run via Steam, and the distro otherwise, but SDL doesn't seem to be one of them. Just: libnettle.so.6.2, libhogweed.so.4.2, librtmp.so.0, libidn.so.11.6.15, libcurl.so.4.2.0. None of which seem likely to be related.)

sulix commented 1 year ago

I managed to track down the darkplaces code that causes the issue: https://github.com/xonotic/darkplaces/blob/a0465ad2ee16719587b0b7a80d4c1c2f7df1ac0e/vid_sdl.c#L2334

It's using the x11.wmwindow field, which sdl12-compat never sets (as there's no SDL2 equivalent). Just setting it to be the same as x11.window fixes it for me (see PR #292), and is only slightly incorrect. (I did the same for x11.fswindow as well, just in case).

Otherwise, adding a quirk to disable SDL12COMPAT_ALLOW_SYSWM seems like the other valid solution: the game has decent fallbacks if SysWM is unavailable.

icculus commented 1 year ago

This appears to be a game based on darkplaces (modified Quake).

Being GPL'd code, you'll find this in your Steam install, too, fwiw:

$HOME/.local/share/Steam/steamapps/common/steelstorm/engine_source.zip

icculus commented 1 year ago

It's using the x11.wmwindow field, which sdl12-compat never sets (as there's no SDL2 equivalent). Just setting it to be the same as x11.window fixes it for me (see PR https://github.com/libsdl-org/sdl12-compat/pull/292), and is only slightly incorrect. (I did the same for x11.fswindow as well, just in case).

I think this is the correct fix. There's no need to turn off sywm with a quirk, as it uses the API correctly, including when not running on X11, and doesn't do anything that seems to upset things if available.

icculus commented 1 year ago

Okay, this is fixed by 32a06ea1f13a1e516a2e0f8e0dcf266fa1d88ada, thanks!

smcv commented 1 year ago

Confirmed fixed with 1.2.64 + 2.26.5.