summaryrefslogtreecommitdiff
path: root/t/run
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-09-20 07:01:24 -0600
committerKarl Williamson <khw@cpan.org>2022-09-20 12:06:25 -0600
commitebb1d9ce1d2cad3a1ef580148b3788cba3524319 (patch)
tree5e3f8d40c6ef9aa295fb39f0fc2c3e0c145f6cb8 /t/run
parent8333937fcf6cd9f5f7a50aa147d4c455505f9484 (diff)
downloadperl-ebb1d9ce1d2cad3a1ef580148b3788cba3524319.tar.gz
locale.c: Workaround for attributes.pm breakage
See https://github.com/Perl/perl5/issues/20155 The root cause of that problem is that under POSIX 2008, when a thread terminates, it causes thread 0 (the controller) to change to the global locale. Commit a7ff7ac caused perl to pay attention to the environment variables in effect at startup for setting the global locale when using the POSIX 2008 locale API. (Previously only the initial per-thread locale was affected.) This causes problems when the initial setting was for a locale that uses a comma as the radix character, but the thread 0 is set to a locale that is expecting a dot as a radix character. Whenever another thread terminates, thread 0 was silently changed to using the global locake, and hence a comma. This caused parse errors. The real solution is to fix thread 0 to remain in its chosen locale. But that fix is not ready in time for 5.37.4, and it is deemed important to get something working for this monthly development release. This commit changes the initial global LC_NUMERIC locale to always be C, hence uses a dot radix. The vast majority of code is expecting a dot. This is not the ultimate fix, but it works around the immediate problem at hand. The test case is courtesy @bram-perl
Diffstat (limited to 't/run')
-rw-r--r--t/run/locale.t25
1 files changed, 25 insertions, 0 deletions
diff --git a/t/run/locale.t b/t/run/locale.t
index d42cca9de7..3b76ee752c 100644
--- a/t/run/locale.t
+++ b/t/run/locale.t
@@ -449,6 +449,31 @@ EOF
EOF
"1,5\n2,5", { stderr => 'devnull' }, "Can do math when radix is a comma"); # [perl 115800]
+ SKIP: {
+ skip "Perl not compiled with 'useithreads'", 1 if ! $Config{'useithreads'};
+
+ local $ENV{LC_ALL} = undef;
+ local $ENV{LC_NUMERIC} = $comma;
+ fresh_perl_is(<<"EOF",
+ use threads;
+
+ my \$x = eval "1.25";
+ print "\$x", "\n"; # number is ok before thread
+ my \$str_x = "\$x";
+
+ my \$thr = threads->create(sub {});
+ \$thr->join();
+
+ print "\$x\n"; # number stringifies the same after thread
+
+ my \$y = eval "1.25";
+ print "\$y\n"; # number is ok after threads
+ print "\$y" eq "\$str_x" || 0; # new number stringifies the same as old number
+EOF
+ "1.25\n1.25\n1.25\n1", { }, "Thread join doesn't disrupt calling thread"
+ ); # [GH 20155]
+ }
+
SKIP: {
unless ($have_strtod) {
skip("no strtod()", 1);