From: Karl Williamson Date: Wed, 21 Oct 2020 10:46:51 +0000 (-0600) Subject: t/loc_tools.pl: Consider thread 0 always locale-safe X-Git-Tag: v5.33.4~138 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/b0441c5bc62aa2ba1980c5ae151db48af58bcfcf t/loc_tools.pl: Consider thread 0 always locale-safe Test files call this code to see if locales are enabled. Prior to this commit, it returned that they were disabled on builds where there are possible races between threads. This was to silence some rarely occurring smoke failures. But that had the result that such builds didn't get locales tested at all, even if there was just a single thread operating. This commit changes it so that when called from other than the main thread on such a system, it returns disabled, but enabled for the main thread. --- diff --git a/t/loc_tools.pl b/t/loc_tools.pl index 1f8a8df..d751e3d 100644 --- a/t/loc_tools.pl +++ b/t/loc_tools.pl @@ -215,8 +215,13 @@ sub locales_enabled(;$) { # normally would be available return 0 if ! defined &DynaLoader::boot_DynaLoader; - # Don't test locales where they aren't safe. - return 0 unless ${^SAFE_LOCALES}; + # Don't test locales where they aren't safe. On systems with unsafe + # threads, for the purposes of testing, we consider the main thread safe, + # and all other threads unsafe. + if (! ${^SAFE_LOCALES}) { + require threads; + return 0 if threads->tid() != 0; + } # If no setlocale, we need the POSIX 2008 alternatives if (! $Config{d_setlocale}) {