Skip to content

pv-adverb: Don't fail if LD_PRELOAD, LD_AUDIT contain duplicates

Simon McVittie requested to merge wip/task302 into main

Steps to reproduce

  1. Install MangoHUD. I used the mangohud package in the Debian 12 prerelease.
  2. Run mangohud steam
  3. Configure an app/game to run in Steam Linux Runtime (I used Floating Point forced to run in scout-on-soldier, but you could probably reproduce this with an app/game like Retroarch that always requires sniper, or a Windows game via a version of Proton that requires soldier or sniper)
  4. Set that app's launch options to mangohud steam-runtime-launch-options -- %command% (probably mangohud %command% would be enough)
  5. Launch it

Expected result

  • Game launches
  • MangoHUD is seen, even if the game is OpenGL (which requires LD_PRELOAD tricks) rather than Vulkan (where layers are enough)

Actual result

E: Unable to create symlink /tmp/pressure-vessel-libs-XXXXXX/x86_64/libMangoHud.so -> /run/host/usr/lib/x86_64-linux-gnu/mangohud/libMangoHud.so: File exists

Proposed fix

  • pv-adverb: Move non-main() sources into a static library

    This will (eventually) let us unit-test them.

  • pv-adverb: Move LD_AUDIT/LD_PRELOAD to another translation unit

    This will let us unit-test them.

  • pv-adverb: Make the special meaning of G_MAXSIZE more self-documenting

  • tests: Add a unit test for pv-adverb's LD_AUDIT, LD_PRELOAD handling

    The fragility of the dependency handling in tests/pressure-vessel/meson.build with scout's toolchain continues to be a mystery to me (especially since Meson wraps the dependency libraries in --begin-group/--end-group which should make the order irrelevant!). By experiment, keeping the current order and only linking one of these libraries seems to be the only thing that works.

  • pv-adverb: Handle duplicate modules in LD_PRELOAD/LD_AUDIT

    If two entries in LD_PRELOAD or LD_AUDIT are literally duplicates of each other (after syntactic path normalization), then we only need to create a symlink the first time, and it isn't a problem that we get EEXIST a second time.

    If two entries are not duplicates but have the same basename, recover by not doing our special handling of LD_PRELOAD/LD_AUDIT modules, and just using the entry as-is. This might provoke "wrong ELF class" warnings, but that's no worse than how gameoverlayrenderer.so already behaves when not using the container runtime.

    steamrt/tasks#302

  • pv-adverb: Add test coverage for steamrt/tasks#302

Edited by Simon McVittie

Merge request reports

Loading