Change 32938 by [EMAIL PROTECTED] on 2008/01/10 21:16:01
The correct solution is to reference count the regexp in PL_reg_curpm,
rather than put in lots of hacks to work round not reference counting
it.
Affected files ...
... //depot/perl/perl.c#844 edit
... //depot/perl/regexec.c#567 edit
Differences ...
==== //depot/perl/perl.c#844 (text) ====
Index: perl/perl.c
--- perl/perl.c#843~32935~ 2008-01-10 09:27:39.000000000 -0800
+++ perl/perl.c 2008-01-10 13:16:01.000000000 -0800
@@ -872,23 +872,6 @@
* REGEXPs in the parent interpreter
* we need to manually ReREFCNT_dec for the clones
*/
- {
- I32 i = AvFILLp(PL_regex_padav) + 1;
- SV * const * const ary = AvARRAY(PL_regex_padav);
-
- while (i) {
- SV * const resv = ary[--i];
-
- if (SvFLAGS(resv) & SVf_BREAK) {
- /* this is PL_reg_curpm, already freed
- * flag is set in regexec.c:S_regtry
- */
- SvFLAGS(resv) &= ~SVf_BREAK;
- /* So stop it pointing to what is now a dead reference. */
- SvROK_off(resv);
- }
- }
- }
SvREFCNT_dec(PL_regex_padav);
PL_regex_padav = NULL;
PL_regex_pad = NULL;
==== //depot/perl/regexec.c#567 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#566~32913~ 2008-01-09 03:40:12.000000000 -0800
+++ perl/regexec.c 2008-01-10 13:16:01.000000000 -0800
@@ -2256,15 +2256,18 @@
#ifdef USE_ITHREADS
{
SV* const repointer = newSViv(0);
- /* so we know which PL_regex_padav element is PL_reg_curpm
- when clearing up in perl_destruct() */
- SvFLAGS(repointer) |= SVf_BREAK;
+ /* this regexp is also owned by the new PL_reg_curpm, which
+ will try to free it. */
av_push(PL_regex_padav, repointer);
PL_reg_curpm->op_pmoffset = av_len(PL_regex_padav);
PL_regex_pad = AvARRAY(PL_regex_padav);
}
#endif
}
+ /* This is safe against NULLs: */
+ ReREFCNT_dec(PM_GETRE(PL_reg_curpm));
+ /* PM_reg_curpm owns a reference to this regexp. */
+ ReREFCNT_inc(rx);
PM_SETRE(PL_reg_curpm, rx);
PL_reg_oldcurpm = PL_curpm;
PL_curpm = PL_reg_curpm;
End of Patch.