You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that getenv and setenv in libc are not thread-safe [1], and most impl of localtime_r in libc directly call getenv [2]. This means that localtime_r may have data race with setenv.
In order to ensure soundness of setenv, libstd add a lock to it [1], but this means that using getenv without libstd will be unsound.
This problem is not easy to reproduce on glibc, because glibc's localtime_r caches timezone. but using musl can easily reproduce it.
I found that
getenvandsetenvin libc are not thread-safe [1], and most impl oflocaltime_rin libc directly callgetenv[2]. This means thatlocaltime_rmay have data race withsetenv.In order to ensure soundness of
setenv, libstd add a lock to it [1], but this means that usinggetenvwithout libstd will be unsound.This problem is not easy to reproduce on glibc, because glibc's
localtime_rcaches timezone. but using musl can easily reproduce it.POC: https://gist.github.com/quininer/2063c31b0bc1753989122e782b182bea