TLDR: Just scroll down to The solution.
Today (2024-03-09) I tried to run Counter-Strike Source on Void Linux via the Flatpak version of Steam on Void Linux. I have updated all my Flatpaks via flatpak update
before I started Steam.
After trying to run Counter-Strike Source, it just stopped. No game window opened. The green Play
button of the game just updated to the blue Stop
button and eventually reverted back to the green Play
button.
So I ran Steam via the console using flatpak run com.valvesoftware.Steam
to look at the logs. The game had problems with line 72 of hl2.sh
, printing
<flatpak game directory>/hl2.sh: line 72: <game PID> Aborted
After some googling I stumbled upon this Reddit thread: https://www.reddit.com/r/linux_gaming/comments/18ykfuz/counter_strike_source_wont_launch/
There, the comment from PM_ME_FLUFFY_SHIBES
was extremely helpful: https://www.reddit.com/r/linux_gaming/comments/18ykfuz/comment/kgejtw3/
Ah you've been hit with the malloc bug when it comes to source engine games. Install
lib32-libjemalloc
and run the game withLD_PRELOAD=$LD_PRELOAD:/usr/lib32/libjemalloc.so.2 %command%
Check out protondb entries for the game.
The package lib32-libjemalloc
on Void Linux is called jemalloc-32bit
. So I went ahead and installed it via XBPS and copied libjemalloc.so.2
to the Steam Flatpak root directory like so:
cp /usr/lib32/libjemalloc.so.2 ~/.var/app/com.valvesoftware.Steam/libjemalloc.so.2
Afterwards I used the LD_PRELOAD
trick: Within the Steam window, right clicked on the game, clicked Properties
and added the following to Launch options
:
LD_PRELOAD=$LD_PRELOAD:/home/<username>/.var/app/com.valvesoftware.Steam/libjemalloc.so.2 %command%
This resulted in the same behavior: Steam didn't start the game and the logs complained about libjemalloc.so.2
with this error: TLS error: cannot allocate memory in static TLS block
So I removed jemalloc-32bit
from my system via XBPS and removed ~/.var/app/com.valvesoftware.Steam/libjemalloc.so.2
as well.
I thought about it for a second and went googling for source engine malloc bug linux
. These exact words spawned this first result: ValveSoftware/csgo-osx-linux#2659
The first suggestion was to disable Steam Input
, but for me it was already disabled. So I scrolled down and found this comment: ValveSoftware/csgo-osx-linux#2659 (comment) which referenced this comment from lisa50469
: ValveSoftware/csgo-osx-linux#2992 (comment)
Running CSGO on Ubuntu 22.04 now. Had to do the following:
cd ./.steam/debian-installation/steamapps/common/Counter-Strike\ Global\ Offensive/linux64/
mv libtcmalloc_minimal.so.0 libtcmalloc_minimal.so.0.orig
sudo apt install libtcmalloc-minimal4
cp /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4.5.9 libtcmalloc_minimal.so.0
The command sudo apt install libtcmalloc-minimal4
was what interested me. So I checked where to find the Void Linux equivalent of libtcmalloc-minimal4
.
After some digging I found it within the Void Linux shlibs
: https://github.com/void-linux/void-packages/blob/master/common/shlibs. Specifically this line: https://github.com/void-linux/void-packages/blob/master/common/shlibs#L1661
libtcmalloc_minimal.so.4 gperftools-2.1.90_1
So I went ahead and installed gperftools-32bit
via XBPS and copied libtcmalloc_minimal.so.4.5.5
to the Steam Flatpak root directory like so:
cp /usr/lib32/libtcmalloc_minimal.so.4.5.5 ~/.var/app/com.valvesoftware.Steam/libtcmalloc_minimal.so.4.5.5
After changing the Launch Options
of Counter-Strike Source to the following, it finally started to run as usual:
LD_PRELOAD=$LD_PRELOAD:/home/<username>/.var/app/com.valvesoftware.Steam/libtcmalloc_minimal.so.4.5.5 %command%
Here, installing gperftools-32bit
might fix the error without using the LD_PRELOAD
trick. If not, try the following Launch Options
:
LD_PRELOAD=$LD_PRELOAD:/usr/lib32/libtcmalloc_minimal.so.4.5.5 %command%
Depending on the installed version of gperftools-32bit
and the corresponding version of libtcmalloc_minimal
, the version string might be different for you, for example 4.5.6
instead of 4.5.5
.