In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/94a5f6597322b09798789257ed58175d9e7462a7?hp=6645d2ed454fabd284e37e08a29cacbfc5b9a3d6>

- Log -----------------------------------------------------------------
commit 94a5f6597322b09798789257ed58175d9e7462a7
Author: David Mitchell <[email protected]>
Date:   Tue Nov 8 12:26:12 2016 +0000

    handle SvIMMORTALs in LHS of list assign
    
    RT #129991: this code fails an assert that the LHS is not SvIMMORTAL:
    
        perl -e  '($_,$0)=(1,0) for 0 gt 0'
    
    The 'set SVf_BREAK flag in a mark and sweep' code I wrote to look for
    common elements, skips PL_sv_undef on the LHS. It should also skip
    other SvIMMORTAL SVs like PL_sv_yes, but the SvIMMORTAL() test is
    more expensive than a simple (sv == &PL_sv_undef), and I couldn't think of
    a case where a LHS would be immortal but not sv_undef.
    
    So I added an assert instead.
    
    The above code shows that it was in fact possible, so test for SvIMMORTAL
    instead.
-----------------------------------------------------------------------

Summary of changes:
 pp_hot.c       | 3 +--
 t/op/aassign.t | 7 +++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/pp_hot.c b/pp_hot.c
index 2731796..cc86d0a 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1163,8 +1163,7 @@ S_aassign_copy_common(pTHX_ SV **firstlelem, SV 
**lastlelem,
                 lcount = -1;
                 lelem--; /* no need to unmark this element */
             }
-            else if (!(do_rc1 && SvREFCNT(svl) == 1) && svl != &PL_sv_undef) {
-                assert(!SvIMMORTAL(svl));
+            else if (!(do_rc1 && SvREFCNT(svl) == 1) && !SvIMMORTAL(svl)) {
                 SvFLAGS(svl) |= SVf_BREAK;
                 marked = TRUE;
             }
diff --git a/t/op/aassign.t b/t/op/aassign.t
index 6d0a3a4..e789210 100644
--- a/t/op/aassign.t
+++ b/t/op/aassign.t
@@ -551,6 +551,13 @@ SKIP: {
 
 }
 
+{
+    # [perl #129991] assert failure in S_aassign_copy_common
+    # the LHS of a list assign can be aliased to an immortal SV;
+    # we used to assert that this couldn't happen
+    eval { ($_,$0)=(1,0) for 0 gt 0 };
+    like($@, qr//, "RT #129991");
+}
 
 
 done_testing();

--
Perl5 Master Repository

Reply via email to