Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128993 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 63B731A00BC for ; Wed, 29 Oct 2025 08:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761727538; bh=T8lhSoASaBKdJqQQS/1YBFFTEI5ooqMqSBAHvlhjCPI=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=RR7gRj91gf9GDtqOGRPdjxt2BVYoqquZPA5WdboMh19SaHWYTHv5AkRO1r+Xkmk7F FrNx7BpL5AgmMjAatv9aiKi/3pgiXLs/AMekbT2VNS2GpdfVYRohEBii7tmxUMvfo6 3GHfcLWbgsLlK4pdFSMtYLsUCDiP21OHQSSkja2D8D4jvwpEqlLOAUvvUhGVE5/ITs f9vBi3Ettc8rcwscQuX1IQGno6wUpNfFakNHwJPplH0TNpfTLjbfgLJPELgd/1mKef r0iu0m+rXknUABVXpCZ6wa8KsomO2cbQOr/W6rbbFzOs9FmIvlrThFTvFOYhbdr+CS WCpRfhV/uXTyg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 44E6D180057 for ; Wed, 29 Oct 2025 08:45:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 29 Oct 2025 08:45:38 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-475dd559a83so24676565e9.1 for ; Wed, 29 Oct 2025 01:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761727532; x=1762332332; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=OskovIJgT0zPWeG86Ljo+1SvjSFZAtsdr+qBStQ93J8=; b=QxZ2kqtvr0p9+lIUkjanpT1kHJFhSb9fVbvraJx7IH6dacctvRBCg8RnRD4SLwjU9b JljKn+V6W3uXly/wwLB1onE/6JH5DoQsG60P6xzVgAEP+MOSI5+rmI2YraVcWO8u4jtk pDDr+T2YepTbide2DAn9xU8zZrBbCRJKcrVyu4NvpG/gKr0jjJ7i+yM1zTjR3wGo0ezT xtfUgphLDlDQPwDqb5Gyqdnvglfkrna2Dflzdd4mOioPdP90B1p9APjAhS6liElKftOh j9tHNoVuZB97bGUHvuWlainYyRpd6oM85xoNTuhCgloxaNfG3itDjHUjtWbIVVMRdiWe Ko+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761727532; x=1762332332; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OskovIJgT0zPWeG86Ljo+1SvjSFZAtsdr+qBStQ93J8=; b=i4pdVG4T6F80q+3rKGOSDnON3COyTyVhNAcgFCB2IUs//pfufqRtcs5wGYZPiHn5qG GEjNOVatTbDDcBm1rlnR4KxcXcnyOY0cXejqSMpviusDZvCPX6Bc92rpr9n8TZZqgSEg hmfCmLcu8e9zD6PGKiSg66wQVELfNnd/lSmOrNkyaDPCQqpp+pmNk/5Kzeh1xGR7WHPk efDT8fzpP4ps1TBshZE7v8b5zfeRN7Qsr7NOMGtbvVjPAs/COI4GFOyvbKU993v9c14+ cPKLQHj75AktASCs/+FulAxzih3zbtnm5+8WMF26pVVSS2+rDRWXG8AH9pL4vUy9XIMn 5bVA== X-Gm-Message-State: AOJu0Yz4QlgFMBUrRwvPPIiafklIQ4xzF+TGRI7lkd+CR59rdhbK5fuz Ipo4lNHgf2NnMHuW0jGi8QmqsS2ofI/mOrF81uny7xky7DWIqOb50sGO X-Gm-Gg: ASbGnctGCCYTlsGMsAtelsWRn2maN45Qj5g53mkOltCTibXpjz9UpbzhujEw5whrvl2 b67MwMfJYz204NPUD26fKJYaO5P81IvQDkaqppjStmMCOjhEcAVsaZjOIgDqzCEa5YZaRQRbSTr roLQ1mHZ3GSdY+x4j0Nc052F62erk/pDBzHHlmI7g6w5W3pBJBOyzDuxwMjBAAJU0Eu6iAIRJFV LRW0e7HOoTInyMEXXqt6yMqjUBG/6qx4Q7TjILx5Xe3wVIUBbMZJ5SXDFIRLWqeNvEh+LCvX24j KzUdpXXIg8WcpGNXHUD6EbmUMKKgW8cBVI7QS6zeSM4jk7GkVmVSkCg4ZI2aCgD3IZMuI1KvqOg 3utcpNGY65HxXPyyCazm70HPidzjY5+LTMTgz7eC4MH46Q+Fw+XNWD/wmHgxfWGHWK3amUshY/c QirxVYc8XVxiJer+oXAA== X-Google-Smtp-Source: AGHT+IGnA4PJBmYIDPtFOFRW9FA1rKmSOE35HnoKfrp1z9mepBLf89i2WNQtsgPcpdgWVNuRA8ASRA== X-Received: by 2002:a05:600c:3b23:b0:475:de12:d3b5 with SMTP id 5b1f17b1804b1-4771e1e3abemr22483085e9.34.1761727531551; Wed, 29 Oct 2025 01:45:31 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4771e196a9asm37161925e9.7.2025.10.29.01.45.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Oct 2025 01:45:30 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_3E02AA98-45CA-4EDB-8BC6-A847016B7F60" Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [PHP-DEV] Change `setlocale()` to use the `uselocale()` C function if available on POSIX too Date: Wed, 29 Oct 2025 09:45:17 +0100 In-Reply-To: Cc: "internals@lists.php.net" To: Marc Henderkes References: X-Mailer: Apple Mail (2.3826.700.81) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_3E02AA98-45CA-4EDB-8BC6-A847016B7F60 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 28 oct. 2025 =C3=A0 16:52, Marc Henderkes a =C3=A9crit : >=20 > Hello everyone, > =20 > 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=E2=80=99t 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 >=20 > On Windows builds, since PHP 7, it is already per-thread, but on POSIX = systems it is not. >=20 > 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=E2=80=99d like to go = ahead and create an RFC. I will also implement the changes in php-src, = I=E2=80=99ve already done so as a proof of concept. >=20 > Thank you for your time, > Marc Henderkes Hi, =46rom 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? =E2=80=94Claude= --Apple-Mail=_3E02AA98-45CA-4EDB-8BC6-A847016B7F60 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 28 oct. 2025 =C3=A0 16:52, Marc Henderkes = <m@pyc.ac> a =C3=A9crit :

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=E2=80=99t 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-34571= 37937

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=E2=80=99d like to go ahead and create an RFC. I will also = implement the changes in php-src, I=E2=80=99ve already done so as a = proof of concept.

Thank you for your time,
Marc = Henderkes

Hi,

<= /div>
=46rom 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?

=E2=80=94Claude
= --Apple-Mail=_3E02AA98-45CA-4EDB-8BC6-A847016B7F60--