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

Workaround for Source 1 libtcmalloc_minimal.so.4 issues no longer works in Steam client beta #1361

Open
smcv opened this issue Oct 31, 2024 · 8 comments

Comments

@smcv
Copy link
Contributor

smcv commented Oct 31, 2024

Game information
A game affected by ValveSoftware/Source-1-Games#5043 (I tested Half-Life 2: Deathmatch and Fistful of Frags)

Distribution name and version where applicable
Probably any distro. I tested on Arch Linux

Flatpak info
Flatpak 1.15.10, default (Mesa) GL driver

Problem description
In the Steam client beta, this app's workaround for games based on the Source 1 engine no longer works.

The problem is that Source 1 games bundle a copy of libtcmalloc_minimal.so.4 which overrides some but not all memory allocation functions. If some other component such as the graphics driver happens to call into the new C++17 aligned new/delete entry points, then the game will crash with an error message similar to this:

src/tcmalloc.cc:278] Attempt to free invalid pointer 0xa657d00 

Until recently, this Flatpak app has been able to work around that issue by installing a LD_AUDIT module (the "shared library guard") and configuring it to refuse to load the game's bundled libtcmalloc_minimal.so.4, resulting in the game instead loading a newer copy of libtcmalloc_minimal.so.4 which is included in this Flatpak app.

However, the Steam client beta runs games in a Steam Linux Runtime 1.0 (scout) container by default, and that container does not have its own copy of libtcmalloc_minimal.so.4. This means that instead of sometimes crashing with Attempt to free invalid pointer, now the game will always crash, with message similar to:

shared-library-guard active for /home/desktop/SteamLibrary/steamapps/common/Fistful of Frags/sdk/hl2_linux
Blocked library /home/desktop/SteamLibrary/steamapps/common/Fistful of Frags/sdk/bin/libtcmalloc_minimal.so.4
/home/desktop/SteamLibrary/steamapps/common/Fistful of Frags/sdk/hl2_linux: error while loading shared libraries: libtcmalloc_minimal.so.4: cannot open shared object file: No such file or directory

You can disable the no-longer-working workaround by setting an affected game's Launch Options to SHARED_LIBRARY_GUARD_CONFIG=/dev/null %command%, but on my test system, that simply returns me to the Attempt to free invalid pointer error.

The ideal solution would be for the affected games to stop using this interposed malloc implementation, but they're rather old and minimally-maintained, so that isn't necessarily going to happen any time soon.

I'm thinking about other possible solutions.

Does this issue reproduce with native Steam
Not on my system. With native Steam, the game's bundled libtcmalloc_minimal.so.4 is loaded, but for whatever reason, ValveSoftware/Source-1-Games#5043 did not seem to be triggered.

@AsciiWolf
Copy link
Contributor

The workaround also hasn't worked in CS: Source for some time now.

@jmaris
Copy link

jmaris commented Nov 16, 2024

This also affects Garrys mod

@luispabon
Copy link

Affects Black Mesa as well

@ClassANetwork
Copy link

ClassANetwork commented Dec 18, 2024

Affects Day of Defeat: Source as well. This issue is particularly with the flatpak.

chdir "/home/xv8/Games/SteamLibrary/steamapps/common/Day of Defeat Source"
ERROR: ld.so: object '/home/xv8/.var/app/com.valvesoftware.Steam/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/xv8/.var/app/com.valvesoftware.Steam/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/xv8/.var/app/com.valvesoftware.Steam/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/xv8/.var/app/com.valvesoftware.Steam/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Game Recording - would start recording game 300, but recording for this game is disabled
Adding process 1343 for gameID 300
ERROR: ld.so: object '/home/xv8/.var/app/com.valvesoftware.Steam/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Adding process 1344 for gameID 300
WARNING: discarding _NET_WM_PID 3082 as invalid for X11 window - use specialized XCB_X11_TO_PID function!
WARNING: discarding _NET_WM_PID 6 as invalid for X11 window - use specialized XCB_X11_TO_PID function!
WARNING: discarding _NET_WM_PID 3082 as invalid for X11 window - use specialized XCB_X11_TO_PID function!
WARNING: discarding _NET_WM_PID 6 as invalid for X11 window - use specialized XCB_X11_TO_PID function!
Adding process 1345 for gameID 300
pid 1435 != 1431, skipping destruction (fork without exec?)
pid 1440 != 1431, skipping destruction (fork without exec?)
Adding process 1431 for gameID 300
pid 1461 != 1431, skipping destruction (fork without exec?)
shared-library-guard active for /home/xv8/Games/SteamLibrary/steamapps/common/Day of Defeat Source/hl2_linux
Blocked library /home/xv8/Games/SteamLibrary/steamapps/common/Day of Defeat Source/bin/libtcmalloc_minimal.so.4
/home/xv8/Games/SteamLibrary/steamapps/common/Day of Defeat Source/hl2_linux: error while loading shared libraries: libtcmalloc_minimal.so.4: cannot open shared object file: No such file or directory
Adding process 1462 for gameID 300
Game Recording - game stopped [gameid=300]
Removing process 1462 for gameID 300
Removing process 1431 for gameID 300
Removing process 1345 for gameID 300
Removing process 1344 for gameID 300
Removing process 1343 for gameID 300

@teihome
Copy link

teihome commented Dec 25, 2024

This is now the Main Client, no-longer just the Beta.

@mrunix00
Copy link

mrunix00 commented Jan 8, 2025

You can disable the no-longer-working workaround by setting an affected game's Launch Options to SHARED_LIBRARY_GUARD_CONFIG=/dev/null %command%
This fixes the issue I have with Black Mesa

@xcom169
Copy link

xcom169 commented Feb 10, 2025

I still have this issue:
/hl2_linux: error while loading shared libraries: libtcmalloc_minimal.so.4: cannot open shared object file: No such file or directory

@Xalalau
Copy link

Xalalau commented Mar 5, 2025

It fixed Garry's Mod, ty.

SHARED_LIBRARY_GUARD_CONFIG=/dev/null %command%

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

No branches or pull requests

9 participants