protonscr

Unsafe calls to setenv() trigger assertion failures but not a full crash

steamopen
ValveSoftware/steam-for-linux#12065 · opened 2025-05-31 by spillner · updated 2025-05-31 · 0 comments · github
Sspillner 2025-05-31 github

System information:

  • Steam client version 1.0.0.83
  • Distribution: Slackware
  • Opted into Steam client beta?: No
  • Have you checked for system updates?: Yes
  • Steam Logs: (attached)
  • GPU: AMD (RX6600XT) using Mesa 25.1.1

What I expected to happen: Steam client produces no significant error messages

What actually happens: Every time I run the Steam client I get the message Assertion Failed: ERROR: unsafe call to setenv count:1 var:'PATH' /data/src/common/linux_setenvwrapper.h:74 on stderr, with a corresponding dump file in /tmp/dumps.

This failure does NOT prevent the rest of the client from starting and running, but it's clearly indicating a misuse of the setenv/getenv API, and could be a background cause of other problems (e.g. memory corruption if one thread is holding a pointer returned from getenv() that was invalidated by another thread's subsequent setenv(), or issues in other processes if environment variable updates are not being passed along as intended).

As noted in the setenv(3) manpage, "CAVEATS: POSIX.1 does not require setenv() or unsetenv() to be reentrant," so calls to these functions should be either definitively confined to a single thread or protected by a mutex. In other words, the assertion is properly calling attention to a potential race condition. You can find a more elaborate discussion of the problem at https://www.evanjones.ca/setenv-is-not-thread-safe.html.

A GDB trace shows that setenv() is called seven times during the Steam client startup on my system. I don't have debugging symbols in my Steam client binary so I was unable to easily generate a useful backtrace.

Steps to reproduce:

  1. Invoke the Steam client through the normal /usr/bin/steam wrapper script

steam-logs.tar.gz

Nothing extracted yet.