diff options
author | Karl Williamson <khw@cpan.org> | 2019-11-24 20:48:54 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-11-26 19:38:14 -0700 |
commit | a8def808210e08cea0b7889fea7c5146b21af4ed (patch) | |
tree | 40bd3017953f36bf853b7dec6c07e818d1d3588e /perl.c | |
parent | e4b61f959ac649d109da4ede1fba8cfa793a79a4 (diff) | |
download | perl-a8def808210e08cea0b7889fea7c5146b21af4ed.tar.gz |
Move regex global variables to interpreter level
This is part of fixing gh #17154
This scenario from the ticket
(https://github.com/Perl/perl5/issues/17154#issuecomment-558877358)
shows why this fix is necessary:
main interpreter initializes PL_AboveLatin1 to an SV it owns
loads threads::lite and creates a new thread/interpreter which
initializes PL_AboveLatin1 to a SV owned by the new interpreter
threads::lite child interpreter finishes, freeing all of its SVs,
PL_AboveLatin1 is now invalid
main interpreter uses a regexp that relies on PL_AboveLatin1, dies
horribly.
By making these interpreter level variables, this is avoided. There is
extra copying, but it is just the SV headers, as the real data is kept
as static C arrays.
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 69 |
1 files changed, 69 insertions, 0 deletions
@@ -1197,6 +1197,75 @@ perl_destruct(pTHXx) PL_warn_locale = NULL; #endif + SvREFCNT_dec(PL_AboveLatin1); + PL_AboveLatin1 = NULL; + SvREFCNT_dec(PL_Assigned_invlist); + PL_Assigned_invlist = NULL; + SvREFCNT_dec(PL_GCB_invlist); + PL_GCB_invlist = NULL; + SvREFCNT_dec(PL_HasMultiCharFold); + PL_HasMultiCharFold = NULL; + SvREFCNT_dec(PL_InMultiCharFold); + PL_InMultiCharFold = NULL; + SvREFCNT_dec(PL_Latin1); + PL_Latin1 = NULL; + SvREFCNT_dec(PL_LB_invlist); + PL_LB_invlist = NULL; + SvREFCNT_dec(PL_SB_invlist); + PL_SB_invlist = NULL; + SvREFCNT_dec(PL_SCX_invlist); + PL_SCX_invlist = NULL; + SvREFCNT_dec(PL_UpperLatin1); + PL_UpperLatin1 = NULL; + SvREFCNT_dec(PL_in_some_fold); + PL_in_some_fold = NULL; + SvREFCNT_dec(PL_utf8_idcont); + PL_utf8_idcont = NULL; + SvREFCNT_dec(PL_utf8_idstart); + PL_utf8_idstart = NULL; + SvREFCNT_dec(PL_utf8_perl_idcont); + PL_utf8_perl_idcont = NULL; + SvREFCNT_dec(PL_utf8_perl_idstart); + PL_utf8_perl_idstart = NULL; + SvREFCNT_dec(PL_utf8_xidcont); + PL_utf8_xidcont = NULL; + SvREFCNT_dec(PL_utf8_xidstart); + PL_utf8_xidstart = NULL; + SvREFCNT_dec(PL_WB_invlist); + PL_WB_invlist = NULL; + SvREFCNT_dec(PL_utf8_toupper); + PL_utf8_toupper = NULL; + SvREFCNT_dec(PL_utf8_totitle); + PL_utf8_totitle = NULL; + SvREFCNT_dec(PL_utf8_tolower); + PL_utf8_tolower = NULL; + SvREFCNT_dec(PL_utf8_tofold); + PL_utf8_tofold = NULL; + SvREFCNT_dec(PL_utf8_tosimplefold); + PL_utf8_tosimplefold = NULL; + SvREFCNT_dec(PL_utf8_charname_begin); + PL_utf8_charname_begin = NULL; + SvREFCNT_dec(PL_utf8_charname_continue); + PL_utf8_charname_continue = NULL; + SvREFCNT_dec(PL_utf8_mark); + PL_utf8_mark = NULL; + SvREFCNT_dec(PL_InBitmap); + PL_InBitmap = NULL; + SvREFCNT_dec(PL_CCC_non0_non230); + PL_CCC_non0_non230 = NULL; + SvREFCNT_dec(PL_Private_Use); + PL_Private_Use = NULL; + + for (i = 0; i < POSIX_CC_COUNT; i++) { + SvREFCNT_dec(PL_XPosix_ptrs[i]); + PL_XPosix_ptrs[i] = NULL; + + if (i != _CC_CASED) { /* A copy of Alpha */ + SvREFCNT_dec(PL_Posix_ptrs[i]); + PL_Posix_ptrs[i] = NULL; + } + } + if (!specialWARN(PL_compiling.cop_warnings)) PerlMemShared_free(PL_compiling.cop_warnings); PL_compiling.cop_warnings = NULL; |