This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pad.c:pad_free: Don’t turn off the PADTMP flag
authorFather Chrysostomos <sprout@cpan.org>
Wed, 27 Aug 2014 02:05:32 +0000 (19:05 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 28 Aug 2014 20:04:16 +0000 (13:04 -0700)
When we mark a pad entry as being free, it may happen (under
USE_BROKEN_PAD_RESET) that multiple operators from different state-
ments are using the same pad entry for their targets.  If we turn off
the PADTMP flag, the slot may be reused for a constant.  Then an oper-
ator that tries to return a value by assigning to its target will try
to modify a read-only scalar.

Now that (as of a few commits ago) allocation of targets (in
pad_alloc) will reuse entries marked PADTMP, turning off the flag is
not necessary to make a slot available.

This gets the build for USE_BROKEN_PAD_RESET+threads a little further.
The Exporter test now passes, but configpm trips an assertion....

pad.c

diff --git a/pad.c b/pad.c
index 7f896c4..87944c2 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -1810,7 +1810,9 @@ Free the SV at offset po in the current pad.
 void
 Perl_pad_free(pTHX_ PADOFFSET po)
 {
+#ifndef USE_BROKEN_PAD_RESET
     SV *sv;
+#endif
     ASSERT_CURPAD_LEGAL("pad_free");
     if (!PL_curpad)
        return;
@@ -1825,10 +1827,11 @@ Perl_pad_free(pTHX_ PADOFFSET po)
            PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long)po)
     );
 
-
+#ifndef USE_BROKEN_PAD_RESET
     sv = PL_curpad[po];
     if (sv && sv != &PL_sv_undef && !SvPADMY(sv))
        SvFLAGS(sv) &= ~SVs_PADTMP;
+#endif
 
     if ((I32)po < PL_padix)
        PL_padix = po - 1;