Re: Change `setlocale()` to use the `uselocale()` C function if available on POSIX too

From: Date: Wed, 29 Oct 2025 08:45:17 +0000
Subject: Re: Change `setlocale()` to use the `uselocale()` C function if available on POSIX too
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-128993@lists.php.net to get a copy of this message
> Le 28 oct. 2025 à 16:52, Marc Henderkes <m@pyc.ac> a écrit : > > Hello everyone, > > We recently noticed that the setlocale function currently uses > setlocale in its C implementation as well > [https://github.com/php/frankenphp/pull/1941], which is a) not multithreading safe to use and b) > when it doesn’t crash, leads to overriding the current locale for the entire process. > For NTS builds with php-fpm this is not an issue, but for FrankenPHP and mod_php, this leads to > unexpected behaviour described here: > https://github.com/php/frankenphp/pull/1941#issuecomment-3457137937 > > On Windows builds, since PHP 7, it is already per-thread, but on POSIX systems it is not. > > I would therefore like to get your reactions on whether it would make sense to unify the > behaviour between POSIX systems and Windows and make the setlocale() > function thread-safe and per-thread, rather than per-process. > In case my proposal sees positive reception, I’d like to go ahead and create an RFC. I will > also implement the changes in php-src, I’ve already done so as a proof of concept. > > Thank you for your time, > Marc Henderkes Hi, From my point of view, the current behaviour (not thread-safe and not per-thread) is obviously a bug, not a feature. I assume that there is no need to create an RFC for fixing a bug? —Claude

« previous php.internals (#128993) next »