TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Improving Steam Client Stability on Linux

477 pointsby Venn16 months ago

23 comments

fweimer6 months ago
We&#x27;ve got patches under review: <a href="https:&#x2F;&#x2F;inbox.sourceware.org&#x2F;libc-alpha&#x2F;cover.1722193092.git.fweimer@redhat.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;inbox.sourceware.org&#x2F;libc-alpha&#x2F;cover.1722193092.git...</a> (triggered by <a href="https:&#x2F;&#x2F;issues.redhat.com&#x2F;browse&#x2F;RHEL-42410" rel="nofollow">https:&#x2F;&#x2F;issues.redhat.com&#x2F;browse&#x2F;RHEL-42410</a>, a graphics stack stability issue that wasn&#x27;t as visible in RHEL 9 for some reason)<p>At least the first one (the getenv thread safety fix) will hopefully make it into glibc 2.41 and it should be quite safe to backport. It turns out that setenv is easier to handle because glibc already never frees environment strings. It&#x27;s concurrent unsetenv that is rather tricky. Without some snapshot approach, getenv would return null pointers instead of environment variables values that are actually set. I don&#x27;t want to introduce locking into getenv because getenv without setenv has been async-signal-safe for so long that it would likely break applications.<p>The environ handling fixes are a bit more controversial because vfork+execve make it complicated to avoid memory leaks, but these further fixes are less important to the stability of the graphics stack.
评论 #42111767 未加载
评论 #42114028 未加载
electromech6 months ago
Thank you! I deeply appreciate that Steam works so well on Linux these days. I don&#x27;t take for granted the hard work happening behind the scenes to make that a reality for us.
评论 #42111469 未加载
vlovich1236 months ago
Isn’t best practice to read all environment variables on boot and never use setenv? The only place where setenv would matter is for spawning new processes where you should probably be creating an new environ cloned from the current one and update the new values. Using getenv&#x2F;setenv as an IPC messaging mechanism seems to be an opportunity for lots of issues aside from it historically not being multithreaded-safe on Linux and having all sorts of potential memory leaks hiding (which is what the post ignores when it says that it’s thread safe on MacOS).
评论 #42117485 未加载
o11c6 months ago
The real question is: is there <i>any</i> case where a program calls `setenv` in one thread and actually <i>wants</i> it to take effect in other already-existing threads?<p>That said, GLIBC <i>is</i> pretty good at documenting all the dangerous functions, so it is <i>possible</i> to add locking&#x2F;copying yourself.
评论 #42111308 未加载
评论 #42112186 未加载
评论 #42111663 未加载
评论 #42117504 未加载
评论 #42111972 未加载
评论 #42119789 未加载
bhawks6 months ago
FWIW the decision to leak memory on Mac actually goes back ~26 years to FreeBSD - <a href="https:&#x2F;&#x2F;bugs.freebsd.org&#x2F;bugzilla&#x2F;show_bug.cgi?id=5604" rel="nofollow">https:&#x2F;&#x2F;bugs.freebsd.org&#x2F;bugzilla&#x2F;show_bug.cgi?id=5604</a> which OSX inherited. I would not be surprised that Windows setenv has BSD roots due to licensing.<p>26 years ago people knew this API was broken but didn&#x27;t fix it due to inertia of breaking buggy programs further.<p>There really shouldn&#x27;t be a need to change your own process&#x27;s envvars. For subprocesses just use the proper exec function. For anything else there should be a clear API to call rather than changing a global variable and hoping some code far away from yours rereads it and handles things correctly.
评论 #42119759 未加载
josephcsible6 months ago
&gt; One of my colleagues rightly dubbed setenv &quot;the worst Linux API&quot;.<p>Is setenv really a Linux API, since it&#x27;s neither defined by Linux (it&#x27;s in POSIX) nor implemented by the Linux kernel (it&#x27;s entirely in userspace)?
评论 #42112165 未加载
评论 #42114661 未加载
评论 #42112040 未加载
INTPenis6 months ago
The mere existence of Steam is astounding to someone who grew up playing nethack and chess on Linux.<p>But the Steam client is really strange. Sometimes it works for months, and suddenly a game won&#x27;t start, or something doesn&#x27;t work, and I have to do weird stuff to get it working like purging all files or reinstalling. It doesn&#x27;t make sense, it&#x27;s like the Steam client rots.
评论 #42114908 未加载
评论 #42117939 未加载
accrual6 months ago
This is really cool insight into both the Steam client and Linux programming. I understand why there may not be detailed release notes every release, but wow &quot;Fixed some miscellaneous common crashes&quot; is an understatement when you know about this work!
bhaney6 months ago
&gt; If this can be addressed in glibc, it may involve a tradeoff on features, maybe an opt-in mechanism with a slight departure from the &quot;impossible&quot; POSIX spec. That&#x27;s something we may pursue in the long term if we can propose something sensible.<p>Yes please
WhyNotHugo6 months ago
I&#x27;m really curious why they&#x27;re using setenv(3) so much. The main usages that I can think of is setting an environment variable before calling something like exec(3). That doesn&#x27;t seem to be the case here.<p>The article mentions that they use exevpe for spawning children processes. So what usages of setenv(3) would remain?
评论 #42114860 未加载
thrdbndndn6 months ago
&gt; We removed the majority of setenv calls. It was mostly used when spawning processes<p>Could someone elaborate this for a non-developer? Why would you use `setenv` (which I assume is functionally similar to `export key=value`, but correctly me if I&#x27;m wrong) (extensively) for spawning processes?
评论 #42113473 未加载
jeffbee6 months ago
Maybe among the best decisions Java ever made was hiding setenv. You simply cannot set env vars in Java.
评论 #42111527 未加载
评论 #42111554 未加载
评论 #42112747 未加载
russnes6 months ago
I love the steam client on linux these days, especially the compatibility for non-steam games is so great and Ive been using it to play WoW Classic while I have covid
Pannoniae6 months ago
To raise awareness: there&#x27;s been a bug with the Linux Steam client which has been persistent for a long time.<p>TL;DR: if you have Steam running for more than a ~day or so, you will run out of window handles so you won&#x27;t be able to open any new graphical application&#x2F;window until you restart Steam.<p>Using Steam Chat appears to make the issue worse (it happens earlier).<p>This has been documented under <a href="https:&#x2F;&#x2F;github.com&#x2F;ValveSoftware&#x2F;steam-for-linux&#x2F;issues&#x2F;9094">https:&#x2F;&#x2F;github.com&#x2F;ValveSoftware&#x2F;steam-for-linux&#x2F;issues&#x2F;9094</a> but for some reason that issue has been closed.<p>I personally just restart Steam every day but if someone else encounters this issue and doesn&#x27;t know why their windows are not opening, this is why :)<p>I am using KDE&#x2F;Wayland but I&#x27;ve observed this under X11 too.
评论 #42111440 未加载
评论 #42111803 未加载
评论 #42111531 未加载
评论 #42112720 未加载
评论 #42113663 未加载
apatheticonion6 months ago
Would love an open source Steam client
arendtio6 months ago
Always cool to rediscover people via HN. This post reminded me of the work ttimo did for the Quake 3 engine more than two decades ago. I remember it because I read so many comments written by him (like 15 years ago):<p><a href="https:&#x2F;&#x2F;github.com&#x2F;search?q=repo%3Aioquake%2Fioq3+ttimo&amp;type=code">https:&#x2F;&#x2F;github.com&#x2F;search?q=repo%3Aioquake%2Fioq3+ttimo&amp;type...</a>
DanielHB6 months ago
I can&#x27;t wait to ditch windows for my tower PC.
nineteen9996 months ago
The stability is fine for me, but the rendering performance in the steam client when the mouse is in the window is abysmal.
评论 #42112703 未加载
matheusmoreira6 months ago
I wish they&#x27;d make it more virtualization friendly. I don&#x27;t want to run untrustworthy proprietary software on my main system. Common sandboxing mechanisms are insufficient since Steam and its games need access to the entire device tree anyway. Nothing short of a real virtual machine would do it for me. Will also make compatibility painless since I can just install the Linux distribution they support.<p>I shopped around for computer parts with complete IOMMU support just so I could map the discrete GPU to the virtual machine and achieve near native performance... Only to discover they are exceendingly hostile to users who do this VFIO stuff.<p>Just yet another reminder not to &quot;buy&quot; games on these platforms, I guess.
评论 #42117767 未加载
Aeolun6 months ago
My only issue with Steam at this point is that it’ll just randomly complain it has no connection, no matter which content server I set it to connect to.<p>If I spam the ‘retry’ button it’ll eventually work, but it’s a massive PITA.
Dwedit6 months ago
On Windows, &quot;Environment&quot; is stored in the Win32 Thread Information Block&#x2F;Thread Environment Block (TIB&#x2F;TEB), so it&#x27;s thread-local rather than process-global.
AzzyHN6 months ago
All of this stuff goes way over my head. I&#x27;m on Pop!_OS and am happy to report &quot;it just works&quot; (tm), though it ignores scaling entirely.
snvzz6 months ago
Considering glibc&#x27;s effort, I have to wonder what the other libc do, and whether they already implement something like this.