Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q81Ck-0005nC-2l for pgsql-bugs@arkaria.postgresql.org; Sat, 10 Jun 2023 16:12:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q81Ci-0002V9-Q2 for pgsql-bugs@arkaria.postgresql.org; Sat, 10 Jun 2023 16:12:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q81Ci-0002V0-HB for pgsql-bugs@lists.postgresql.org; Sat, 10 Jun 2023 16:12:40 +0000 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q81Cg-001HmY-2B for pgsql-bugs@lists.postgresql.org; Sat, 10 Jun 2023 16:12:39 +0000 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-565aa2cc428so25723077b3.1 for ; Sat, 10 Jun 2023 09:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joeconway.com; s=google; t=1686413557; x=1689005557; h=in-reply-to:subject:references:cc:to:from:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=CxutW4HRiZjEG8RDliJhmLtaF46VqkxSJbaApDtnNrM=; b=X38105yRJ8qVh6NpX72oTpUrm3CpB03QUXahstEAnraxumC9fNBatfGhlmY0GZrArr WCPxw2I8ecoND7BrgnDvw7rXzNJVU2Chunaee2iWWnb5C084/1GworJ4GNrbtaFviaTe he/axDma0poxVgbbCZaYElxLHzp07QZVIW/fL7ucARzlLd7+8fmxTx3EFdNQ6ODqtcqK XkQ3BT0N7myIzuP8YSvtljuvG4aYom08OYopRVbhaWU6FHVY+o7yYVWvEJhoCLnRxlKV Ww66AVWcPdz8oXSt9ZZ1o3jt/9E/EI6WWyCeGBEFoNTv95rPaCm5WBTjd1Si2+tpcMUf /Uhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686413557; x=1689005557; h=in-reply-to:subject:references:cc:to:from:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=CxutW4HRiZjEG8RDliJhmLtaF46VqkxSJbaApDtnNrM=; b=Uw+8V9pl/ohalVsFWDfKZmsGO1BuvlGFRqxFGUlzLYwX/CBmJ3EP8gy9rzF68xDVzf gqXYnY32cDmTZscbrEkZq68a/U8CWFF06c5ZQu3aKWd06w/5uhWM2FpiWhjFExBP6sne Mymle8bf3a0IoJwaMsUZHzPAKYGoeKXy7vXgeB6smfXGjIyle/Uo/eV252Ca0RwpuWEA I/d4X5WoSLg5zMo+CUz+Ch0Cb35huHcq5/sHpMT3B6wN8rYvCDnqYkZ7vb+z1QsG49es cyxJu3Dx7Rl5LSPGnFcsevAregXTsBDFY08aaMoi5raTx20VhqjMNQCFuwrLKzNGkCjI n2yA== X-Gm-Message-State: AC+VfDxatPg+8WTloRwVM8WqbAF9eHuT/rQOjilXfvUFoO4PIzg2nord ZiJKpzg1/XZBlKFH8jtFcqlCJg== X-Google-Smtp-Source: ACHHUZ4/bHUKdrsenuRx7clW31GNr49ZRiGmXmdLpNSFbEN7QEcNiMbQawoJM/o/MD2u1wpQy4Z4tA== X-Received: by 2002:a81:de53:0:b0:561:b58e:31ff with SMTP id o19-20020a81de53000000b00561b58e31ffmr4201288ywl.44.1686413557229; Sat, 10 Jun 2023 09:12:37 -0700 (PDT) Received: from [192.168.4.41] (162-239-31-113.lightspeed.dybhfl.sbcglobal.net. [162.239.31.113]) by smtp.gmail.com with ESMTPSA id q67-20020a818046000000b0054f83731ad2sm1361859ywf.0.2023.06.10.09.12.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 10 Jun 2023 09:12:36 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------8smtouUUA1FwROR6GJslcnzx" Message-ID: Date: Sat, 10 Jun 2023 12:12:36 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US From: Joe Conway To: Tristan Partin , Heikki Linnakangas , Tom Lane , gdo@leader.it Cc: pgsql-bugs@lists.postgresql.org References: <17946-3e84cb577e9551c3@postgresql.org> <1564676.1685043220@sss.pgh.pa.us> <555bb26e-c27c-ab65-028f-3fd5b82df9de@iki.fi> <5676b739-0854-f924-4b97-466e3504c692@joeconway.com> Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG In-Reply-To: <5676b739-0854-f924-4b97-466e3504c692@joeconway.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------8smtouUUA1FwROR6GJslcnzx Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 6/9/23 22:10, Joe Conway wrote: > On 6/9/23 15:05, Joe Conway wrote: >> I wonder if it isn't a behavior change in libperl itself. It seems >> that merely doing "load 'plperl';" is enough to cause the issue > I can reproduce with a simple test program by linking libperl: > > 8<-------- test.c ---------------- A bit more spelunking leads me to the following observations and conclusions: 1/ On RHEL7 with perl v5.16.3 the problem does not occur 2/ On RHEL9 with perl v5.32.1 the problem does occur 3/ The difference in behavior is triggered by the newer perl doing a bunch of newlocale/uselocale calls not done by the older perl, combined with a glibc behavior which seems surprising at best. From localeinfo.h in glibc source tree: 8<------------------------ /* This fetches the thread-local locale_t pointer, either one set with uselocale or &_nl_global_locale. */ #define _NL_CURRENT_LOCALE (__libc_tsd_get (locale_t, LOCALE)) 8<------------------------ 4/ I successfully tested a fix in the simplified reproducer program sent earlier. It amounts to adding: 8<------------------------ uselocale(LC_GLOBAL_LOCALE); 8<------------------------ prior to calling 8<------------------------ extlconv = localeconv(); 8<------------------------ 5/ The attached fixes the issue for me on pg10 and passes check-world. Comments? -- Joe Conway PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --------------8smtouUUA1FwROR6GJslcnzx Content-Type: text/x-patch; charset=UTF-8; name="20230610-plperl_locale_issue-000.patch" Content-Disposition: attachment; filename="20230610-plperl_locale_issue-000.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL3V0aWxzL2FkdC9wZ19sb2NhbGUuYyBiL3NyYy9i YWNrZW5kL3V0aWxzL2FkdC9wZ19sb2NhbGUuYwppbmRleCBiYmYxMDBlLi41NjBhMzI0IDEw MDY0NAoqKiogYS9zcmMvYmFja2VuZC91dGlscy9hZHQvcGdfbG9jYWxlLmMKLS0tIGIvc3Jj L2JhY2tlbmQvdXRpbHMvYWR0L3BnX2xvY2FsZS5jCioqKioqKioqKioqKioqKiBQR0xDX2xv Y2FsZWNvbnYodm9pZCkKKioqIDU2Miw1NjcgKioqKgotLS0gNTYyLDU3NCAtLS0tCiAgCXNl dGxvY2FsZShMQ19DVFlQRSwgbG9jYWxlX251bWVyaWMpOwogICNlbmRpZgogIAorICAgICAg ICAgLyoKKyAgICAgICAgICAqIEVuc3VyZSB0aGUgZ2xvYmFsIGxvY2FsZSBpcyBiZWluZyB1 c2VkLiBUaGlzIGlzCisgICAgICAgICAgKiBuZWNlc3NhcnksIGZvciBleGFtcGxlLCBpZiBh bm90aGVyIGxvYWRlZCBsaWJyYXJ5CisgICAgICAgICAgKiBzdWNoIGFzIGxpYnBlcmwgaGFz IGRvbmUgdXNlbG9jYWxlKCkgdW5kZXJuZWF0aCB1cy4KKyAgICAgICAgICAqICovCisgICAg ICAgICB1c2Vsb2NhbGUoTENfR0xPQkFMX0xPQ0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