diff --git a/locale.c b/locale.c index 8a2ee4f0683d..e708f7fd9a74 100644 --- a/locale.c +++ b/locale.c @@ -5011,6 +5011,15 @@ Perl_init_i18nl10n(pTHX_ int printwarn) /* Done with finding the locales; update the auxiliary records */ new_LC_ALL(NULL); +# if defined(USE_POSIX_2008_LOCALE) && defined(USE_LOCALE_NUMERIC) + + /* This is a temporary workaround for #20155, to avoid issues where the + * global locale wants a radix different from the per-thread one. This + * restores behavior for LC_NUMERIC to what it was before a7ff7ac. */ + posix_setlocale(LC_NUMERIC, "C"); + +# endif + for (i = 0; i < NOMINAL_LC_ALL_INDEX; i++) { Safefree(curlocales[i]); } diff --git a/t/run/locale.t b/t/run/locale.t index d42cca9de7ab..3b76ee752ce2 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);