summaryrefslogtreecommitdiff
path: root/perlvars.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-11-30 09:46:34 -0700
committerKarl Williamson <khw@cpan.org>2020-12-08 06:44:20 -0700
commitd9e22c6a8a05aab7fffdbf810f74ddfcb4efd752 (patch)
treee07ddc2c28e07f5e4f7b7b100265627111a89e41 /perlvars.h
parent8609fe004ed37605b00f517feb6e9c8eb127952c (diff)
downloadperl-d9e22c6a8a05aab7fffdbf810f74ddfcb4efd752.tar.gz
Refactor locale mutex setup
This was prompted by my realization that even on a locale thread-safe platform, there are functions we call that may not be thread-safe in that they return their results in an internal static buffer, which may be process-wide instead of per-thread. Tomasz Konojacki++ briefly looked at Windows source code for localeconv() and this indeed did appear to be the case. If we thought a platform was thread-safe, no locale mutexes were set up, and instead the calls in the code to lock were no-oops. This would lead to potential races, the most likely candidate being localeconv(). None have been reported, at least as far as we know. Likely that function isn't called frequently. This would be true on both Posix 2008 and Windows platforms, except possibly for FreeBSD, which may be the only platform that we support that has a localeconv_l() function, which is supposed to be immune from this issue.. The solution adopted here is to test for all the possible functions that the Perl core uses that may be susceptible to this, and to set up the mutex if any are found. Thus there won't be no-ops where there should be a lock.
Diffstat (limited to 'perlvars.h')
-rw-r--r--perlvars.h2
1 files changed, 0 insertions, 2 deletions
diff --git a/perlvars.h b/perlvars.h
index a479df741e..1bbe5e3ed3 100644
--- a/perlvars.h
+++ b/perlvars.h
@@ -105,9 +105,7 @@ PERLVARI(G, mmap_page_size, IV, 0)
#if defined(USE_ITHREADS)
PERLVAR(G, hints_mutex, perl_mutex) /* Mutex for refcounted he refcounting */
PERLVAR(G, env_mutex, perl_mutex) /* Mutex for accessing ENV */
-# if ! defined(USE_THREAD_SAFE_LOCALE) || defined(TS_W32_BROKEN_LOCALECONV)
PERLVAR(G, locale_mutex, perl_mutex) /* Mutex related to locale handling */
-# endif
# ifndef USE_THREAD_SAFE_LOCALE
PERLVAR(G, lc_numeric_mutex, perl_mutex) /* Mutex for switching LC_NUMERIC */
# endif