Skip to content

Commit 668d199

Browse files
khwilliamsonxsawyerx
authored andcommitted
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 #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 e80a011 (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 e80a011.
1 parent cac6698 commit 668d199

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

embedvar.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
#define PL_unsafe (vTHX->Iunsafe)
353353
#define PL_utf8_charname_begin (vTHX->Iutf8_charname_begin)
354354
#define PL_utf8_charname_continue (vTHX->Iutf8_charname_continue)
355+
#define PL_utf8_foldclosures (vTHX->Iutf8_foldclosures)
355356
#define PL_utf8_idcont (vTHX->Iutf8_idcont)
356357
#define PL_utf8_idstart (vTHX->Iutf8_idstart)
357358
#define PL_utf8_mark (vTHX->Iutf8_mark)
@@ -497,8 +498,6 @@
497498
#define PL_Guser_def_props_aTHX (my_vars->Guser_def_props_aTHX)
498499
#define PL_user_prop_mutex (my_vars->Guser_prop_mutex)
499500
#define PL_Guser_prop_mutex (my_vars->Guser_prop_mutex)
500-
#define PL_utf8_foldclosures (my_vars->Gutf8_foldclosures)
501-
#define PL_Gutf8_foldclosures (my_vars->Gutf8_foldclosures)
502501
#define PL_veto_cleanup (my_vars->Gveto_cleanup)
503502
#define PL_Gveto_cleanup (my_vars->Gveto_cleanup)
504503
#define PL_watch_pvx (my_vars->Gwatch_pvx)

intrpvar.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,10 @@ PERLVAR(I, UpperLatin1, SV *) /* Code points 128 - 255 */
915915
/* List of characters that participate in any fold defined by Unicode */
916916
PERLVAR(I, in_some_fold, SV *)
917917

918+
/* Everything that folds to a given character, for case insensitivity regex
919+
* matching */
920+
PERLVAR(I, utf8_foldclosures, SV *)
921+
918922
PERLVAR(I, utf8_idcont, SV *)
919923
PERLVAR(I, utf8_idstart, SV *)
920924
PERLVAR(I, utf8_perl_idcont, SV *)

perl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,8 @@ perl_destruct(pTHXx)
11981198
PL_UpperLatin1 = NULL;
11991199
SvREFCNT_dec(PL_in_some_fold);
12001200
PL_in_some_fold = NULL;
1201+
SvREFCNT_dec(PL_utf8_foldclosures);
1202+
PL_utf8_foldclosures = NULL;
12011203
SvREFCNT_dec(PL_utf8_idcont);
12021204
PL_utf8_idcont = NULL;
12031205
SvREFCNT_dec(PL_utf8_idstart);

perlapi.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ END_EXTERN_C
215215
#define PL_user_def_props_aTHX (*Perl_Guser_def_props_aTHX_ptr(NULL))
216216
#undef PL_user_prop_mutex
217217
#define PL_user_prop_mutex (*Perl_Guser_prop_mutex_ptr(NULL))
218-
#undef PL_utf8_foldclosures
219-
#define PL_utf8_foldclosures (*Perl_Gutf8_foldclosures_ptr(NULL))
220218
#undef PL_veto_cleanup
221219
#define PL_veto_cleanup (*Perl_Gveto_cleanup_ptr(NULL))
222220
#undef PL_watch_pvx

perlvars.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,6 @@ PERLVAR(G, user_prop_mutex, perl_mutex) /* Mutex for manipulating
305305
PL_user_defined_properties */
306306
#endif
307307

308-
/* Everything that folds to a given character, for case insensitivity regex
309-
* matching */
310-
PERLVAR(G, utf8_foldclosures, SV *)
311-
312308
/* these record the best way to perform certain IO operations while
313309
* atomically setting FD_CLOEXEC. On the first call, a probe is done
314310
* and the result recorded for use by subsequent calls.

sv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15731,6 +15731,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
1573115731
PL_SCX_invlist = sv_dup_inc(proto_perl->ISCX_invlist, param);
1573215732
PL_UpperLatin1 = sv_dup_inc(proto_perl->IUpperLatin1, param);
1573315733
PL_in_some_fold = sv_dup_inc(proto_perl->Iin_some_fold, param);
15734+
PL_utf8_foldclosures = sv_dup_inc(proto_perl->Iutf8_foldclosures, param);
1573415735
PL_utf8_idcont = sv_dup_inc(proto_perl->Iutf8_idcont, param);
1573515736
PL_utf8_idstart = sv_dup_inc(proto_perl->Iutf8_idstart, param);
1573615737
PL_utf8_perl_idcont = sv_dup_inc(proto_perl->Iutf8_perl_idcont, param);

0 commit comments

Comments
 (0)