summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-05-18 14:40:04 -0600
committerSawyer X <xsawyerx@cpan.org>2020-06-02 12:17:47 +0300
commit668d19980931e86058b46a58d0328c3b881b8aa1 (patch)
tree24af2a04d7083dfb544b75a6920ce1cc48fa36f0
parentcac6698e074af8daec0f7011cd77824d5d849d6f (diff)
downloadperl-668d19980931e86058b46a58d0328c3b881b8aa1.tar.gz
Make PL_utf8_foldclosures interpreter level
This resolves #17774. This ticket is because the fixes in GH #17154 failed to get every case, leaving this one outlier to be fixed by this commit. The text in https://github.com/Perl/perl5/issues/17154 gives extensive details as to the problem. But briefly, in an attempt to speed up interpreter cloning, I moved certain SVs from interpreter level to global level in e80a0113c4a8036dfb22aec44d0a9feb65d36fed (v5.27.11, March 2018). This was doable, we thought, because the content of these SVs is constant throughout the life of the program, so no need to copy them when cloning a new interpreter or thread. However when an interpreter exits, all its SVs get cleaned up, which caused these to become garbage in applications where another interpreter remains running. This circumstance is rare enough that the bug wasn't reported until September 2019, #17154. I made an initial attempt to fix the problem, and closed that ticket, but I overlooked one of the variables, which was reported in #17774, which this commit addresses. Effectively the behavior is reverted to the way it was before e80a0113c4a8036dfb22aec44d0a9feb65d36fed.
-rw-r--r--embedvar.h3
-rw-r--r--intrpvar.h4
-rw-r--r--perl.c2
-rw-r--r--perlapi.h2
-rw-r--r--perlvars.h4
-rw-r--r--sv.c1
6 files changed, 8 insertions, 8 deletions
diff --git a/embedvar.h b/embedvar.h
index 5b6aa2b82a..de1aa999a8 100644
--- a/embedvar.h
+++ b/embedvar.h
@@ -352,6 +352,7 @@
#define PL_unsafe (vTHX->Iunsafe)
#define PL_utf8_charname_begin (vTHX->Iutf8_charname_begin)
#define PL_utf8_charname_continue (vTHX->Iutf8_charname_continue)
+#define PL_utf8_foldclosures (vTHX->Iutf8_foldclosures)
#define PL_utf8_idcont (vTHX->Iutf8_idcont)
#define PL_utf8_idstart (vTHX->Iutf8_idstart)
#define PL_utf8_mark (vTHX->Iutf8_mark)
@@ -497,8 +498,6 @@
#define PL_Guser_def_props_aTHX (my_vars->Guser_def_props_aTHX)
#define PL_user_prop_mutex (my_vars->Guser_prop_mutex)
#define PL_Guser_prop_mutex (my_vars->Guser_prop_mutex)
-#define PL_utf8_foldclosures (my_vars->Gutf8_foldclosures)
-#define PL_Gutf8_foldclosures (my_vars->Gutf8_foldclosures)
#define PL_veto_cleanup (my_vars->Gveto_cleanup)
#define PL_Gveto_cleanup (my_vars->Gveto_cleanup)
#define PL_watch_pvx (my_vars->Gwatch_pvx)
diff --git a/intrpvar.h b/intrpvar.h
index b888f0f998..23de9d9cee 100644
--- a/intrpvar.h
+++ b/intrpvar.h
@@ -915,6 +915,10 @@ PERLVAR(I, UpperLatin1, SV *) /* Code points 128 - 255 */
/* List of characters that participate in any fold defined by Unicode */
PERLVAR(I, in_some_fold, SV *)
+/* Everything that folds to a given character, for case insensitivity regex
+ * matching */
+PERLVAR(I, utf8_foldclosures, SV *)
+
PERLVAR(I, utf8_idcont, SV *)
PERLVAR(I, utf8_idstart, SV *)
PERLVAR(I, utf8_perl_idcont, SV *)
diff --git a/perl.c b/perl.c
index 422a548bd3..2013a76026 100644
--- a/perl.c
+++ b/perl.c
@@ -1198,6 +1198,8 @@ perl_destruct(pTHXx)
PL_UpperLatin1 = NULL;
SvREFCNT_dec(PL_in_some_fold);
PL_in_some_fold = NULL;
+ SvREFCNT_dec(PL_utf8_foldclosures);
+ PL_utf8_foldclosures = NULL;
SvREFCNT_dec(PL_utf8_idcont);
PL_utf8_idcont = NULL;
SvREFCNT_dec(PL_utf8_idstart);
diff --git a/perlapi.h b/perlapi.h
index f3ef930c06..305c11d413 100644
--- a/perlapi.h
+++ b/perlapi.h
@@ -215,8 +215,6 @@ END_EXTERN_C
#define PL_user_def_props_aTHX (*Perl_Guser_def_props_aTHX_ptr(NULL))
#undef PL_user_prop_mutex
#define PL_user_prop_mutex (*Perl_Guser_prop_mutex_ptr(NULL))
-#undef PL_utf8_foldclosures
-#define PL_utf8_foldclosures (*Perl_Gutf8_foldclosures_ptr(NULL))
#undef PL_veto_cleanup
#define PL_veto_cleanup (*Perl_Gveto_cleanup_ptr(NULL))
#undef PL_watch_pvx
diff --git a/perlvars.h b/perlvars.h
index 0892332a63..cd1523d5df 100644
--- a/perlvars.h
+++ b/perlvars.h
@@ -305,10 +305,6 @@ PERLVAR(G, user_prop_mutex, perl_mutex) /* Mutex for manipulating
PL_user_defined_properties */
#endif
-/* Everything that folds to a given character, for case insensitivity regex
- * matching */
-PERLVAR(G, utf8_foldclosures, SV *)
-
/* these record the best way to perform certain IO operations while
* atomically setting FD_CLOEXEC. On the first call, a probe is done
* and the result recorded for use by subsequent calls.
diff --git a/sv.c b/sv.c
index fb1b9fd412..9c7f3ba45e 100644
--- a/sv.c
+++ b/sv.c
@@ -15731,6 +15731,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
PL_SCX_invlist = sv_dup_inc(proto_perl->ISCX_invlist, param);
PL_UpperLatin1 = sv_dup_inc(proto_perl->IUpperLatin1, param);
PL_in_some_fold = sv_dup_inc(proto_perl->Iin_some_fold, param);
+ PL_utf8_foldclosures = sv_dup_inc(proto_perl->Iutf8_foldclosures, param);
PL_utf8_idcont = sv_dup_inc(proto_perl->Iutf8_idcont, param);
PL_utf8_idstart = sv_dup_inc(proto_perl->Iutf8_idstart, param);
PL_utf8_perl_idcont = sv_dup_inc(proto_perl->Iutf8_perl_idcont, param);