diff options
author | Karl Williamson <khw@cpan.org> | 2020-12-13 13:06:42 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-06-11 15:21:39 -0600 |
commit | c3c9077b28cc7017aecd9764ab49af9662ce9b0b (patch) | |
tree | ace4a261fffacbfccb390bd86fcede8d02b59ee7 /embed.fnc | |
parent | 12865d70b33295cc1e31678404f5aef517d3a97b (diff) | |
download | perl-c3c9077b28cc7017aecd9764ab49af9662ce9b0b.tar.gz |
Make fc(), qr//i thread-safe on participating platforms
A long standing bug in Perl that has gone undetected is that the array
is global that is created when changing locales and tells fc() and qr//i
matching what the folds are in the new locale.
What this means is that any program only has one set of fold definitions
that apply to all threads within it, even if we claim that the locales
are thread-safe on the given platform. One possibility for this going
undetected so long is that no one is using locales on multi-threaded
systems much. Another possibility is that modern UTF-8 locales have the
same set of folds as any other one.
It is a simple matter to make the fold array per-thread instead of
per-process, and that solves the problem transparently to other code.
I discovered this stress-testing locale handling under threads. That
test will be added in a future commit.
In order to keep from having a dTHX inside foldEQ_locale, it has to have
a pTHX_ parameter. This means that the other functions that function
pointer variables get assigned to point to have to have an identical
signature, which means adding pTHX_ to functions that don't require it.
The bodies of all these are known to the compiler, since they are all
in inline.h or in the same .c file as where they are called. Hence the
compiler can optimize out the unused parameter.
Two calls of STR_WITH_LEN also have to be changed because of C
preprocessor limitations; perhaps there is another way to do it that I'm
unfamiliar with.
Diffstat (limited to 'embed.fnc')
-rw-r--r-- | embed.fnc | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1074,9 +1074,9 @@ ApbMx |SV** |hv_store_flags |NULLOK HV *hv|NULLOK const char *key \ Amd |void |hv_undef |NULLOK HV *hv poX |void |hv_undef_flags |NULLOK HV *hv|U32 flags AdmP |I32 |ibcmp |NN const char* a|NN const char* b|I32 len -AdiTp |I32 |foldEQ |NN const char* a|NN const char* b|I32 len +Adip |I32 |foldEQ |NN const char* a|NN const char* b|I32 len AdmP |I32 |ibcmp_locale |NN const char* a|NN const char* b|I32 len -AiTpd |I32 |foldEQ_locale |NN const char* a|NN const char* b|I32 len +Aipd |I32 |foldEQ_locale |NN const char* a|NN const char* b|I32 len Adm |I32 |ibcmp_utf8 |NN const char *s1|NULLOK char **pe1|UV l1 \ |bool u1|NN const char *s2|NULLOK char **pe2 \ |UV l2|bool u2 @@ -1086,7 +1086,7 @@ Amd |I32 |foldEQ_utf8 |NN const char *s1|NULLOK char **pe1|UV l1 \ Cp |I32 |foldEQ_utf8_flags |NN const char *s1|NULLOK char **pe1|UV l1 \ |bool u1|NN const char *s2|NULLOK char **pe2 \ |UV l2|bool u2|U32 flags -CiTp |I32 |foldEQ_latin1 |NN const char* a|NN const char* b|I32 len +Cip |I32 |foldEQ_latin1 |NN const char* a|NN const char* b|I32 len #if defined(PERL_IN_DOIO_C) SR |bool |ingroup |Gid_t testgid|bool effective #endif @@ -2458,7 +2458,7 @@ ESR |WB_enum|backup_one_WB |NN WB_enum * previous \ |NN const U8 * const strbeg \ |NN U8 ** curpos \ |const bool utf8_target -EiT |I32 |foldEQ_latin1_s2_folded|NN const char* a|NN const char* b|I32 len +Ei |I32 |foldEQ_latin1_s2_folded|NN const char* a|NN const char* b|I32 len # ifdef DEBUGGING ES |void |dump_exec_pos |NN const char *locinput|NN const regnode *scan|NN const char *loc_regeol\ |NN const char *loc_bostr|NN const char *loc_reg_starttry|const bool do_utf8|const U32 depth |