In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/613a9ec2cfb133a94ef11f3e50bdfef024885d96?hp=65c7421c80585e0d12a20773935dc01f4ffa3e42>

- Log -----------------------------------------------------------------
commit 613a9ec2cfb133a94ef11f3e50bdfef024885d96
Author: David Mitchell <[email protected]>
Date:   Fri Jun 4 21:30:18 2010 +0100

    fix indendation of DM_* flag definitions

M       gv.h

commit 6ca8229ddb2de12c1f8f877d70989420b70a8072
Author: David Mitchell <[email protected]>
Date:   Fri Jun 4 21:28:20 2010 +0100

    express DM_[GU]ID flags in terms of components

M       gv.h

commit 354b0578ec63c058cd73f018f484808b22cc8631
Author: David Mitchell <[email protected]>
Date:   Fri Jun 4 21:25:07 2010 +0100

    rename DM_ARRAY flag to DM_ARRAY_ISA
    
    This better represents its current role as specifically delaying magic on
    @ISA as opposed to a general array magic delay mechanism.

M       av.c
M       gv.h
M       mg.c
M       pp.c
M       pp_hot.c

commit 3a19377ba2315fce9354aa3f06bafbbbab740f1b
Author: David Mitchell <[email protected]>
Date:   Fri Jun 4 21:16:48 2010 +0100

    belatedly add a test for RT #51636:
    
    segmentation fault with array ties

M       t/op/tie.t

commit 8ef242405b8c660c02e953dbc987fbc06897af10
Author: David Mitchell <[email protected]>
Date:   Fri Jun 4 21:01:43 2010 +0100

    Revert "Re: [perl #51636] segmentation fault with array ties"
    
    This reverts commit 90630e3c741716305d7f1da4df5eab5c1bee42cc.
    
    This fix turns out to be wrong, and also made ($<,$>)=(...) fail
    (RT #75212).
    
    The original problem was a SEGV in av_clear(). This was mis-diagnosed
    as recursive PL_delaymagic issue, and the fix was to temprarily reset
    PL_delaymagic to zero. This stopped the mg_set() of $> and $> being
    delayed.
    
    The real problem was that mg_free wasn't clearing the [GSR]MG flags
    after freeing xmg_magic. This was independently fixed by commit
    68f8932eb570af656553ed44c11a23f0a216a3ec.

M       pp_hot.c
-----------------------------------------------------------------------

Summary of changes:
 av.c       |    4 ++--
 gv.h       |   16 ++++++++--------
 mg.c       |    2 +-
 pp.c       |    2 +-
 pp_hot.c   |   24 ++++--------------------
 t/op/tie.t |   16 ++++++++++++++++
 6 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/av.c b/av.c
index 219870c..6e45b95 100644
--- a/av.c
+++ b/av.c
@@ -365,7 +365,7 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val)
            sv_magic(val, MUTABLE_SV(av), toLOWER(mg->mg_type), 0, key);
        }
        if (PL_delaymagic && mg->mg_type == PERL_MAGIC_isa)
-           PL_delaymagic |= DM_ARRAY;
+           PL_delaymagic |= DM_ARRAY_ISA;
        else
           mg_set(MUTABLE_SV(av));
     }
@@ -446,7 +446,7 @@ Perl_av_clear(pTHX_ register AV *av)
     if (SvRMAGICAL(av)) {
        const MAGIC* const mg = SvMAGIC(av);
        if (PL_delaymagic && mg && mg->mg_type == PERL_MAGIC_isa)
-           PL_delaymagic |= DM_ARRAY;
+           PL_delaymagic |= DM_ARRAY_ISA;
         else
            mg_clear(MUTABLE_SV(av)); 
     }
diff --git a/gv.h b/gv.h
index 7e412e5..54722b7 100644
--- a/gv.h
+++ b/gv.h
@@ -168,14 +168,14 @@ Return the SV from the GV.
 #  define Nullgv Null(GV*)
 #endif
 
-#define DM_UID   0x003
-#define DM_RUID   0x001
-#define DM_EUID   0x002
-#define DM_ARRAY 0x004
-#define DM_GID   0x030
-#define DM_RGID   0x010
-#define DM_EGID   0x020
-#define DM_DELAY 0x100
+#define DM_RUID      0x001
+#define DM_EUID      0x002
+#define DM_UID       (DM_RUID|DM_EUID)
+#define DM_ARRAY_ISA 0x004
+#define DM_RGID      0x010
+#define DM_EGID      0x020
+#define DM_GID       (DM_RGID|DM_EGID)
+#define DM_DELAY     0x100
 
 /*
  * symbol creation flags, for use in gv_fetchpv() and get_*v()
diff --git a/mg.c b/mg.c
index 7c7c03e..24561a2 100644
--- a/mg.c
+++ b/mg.c
@@ -1557,7 +1557,7 @@ Perl_magic_setisa(pTHX_ SV *sv, MAGIC *mg)
     PERL_UNUSED_ARG(sv);
 
     /* Skip _isaelem because _isa will handle it shortly */
-    if (PL_delaymagic & DM_ARRAY && mg->mg_type == PERL_MAGIC_isaelem)
+    if (PL_delaymagic & DM_ARRAY_ISA && mg->mg_type == PERL_MAGIC_isaelem)
        return 0;
 
     return magic_clearisa(NULL, mg);
diff --git a/pp.c b/pp.c
index 2649c7e..4c98581 100644
--- a/pp.c
+++ b/pp.c
@@ -5349,7 +5349,7 @@ PP(pp_push)
                sv_setsv(sv, *MARK);
            av_store(ary, AvFILLp(ary)+1, sv);
        }
-       if (PL_delaymagic & DM_ARRAY)
+       if (PL_delaymagic & DM_ARRAY_ISA)
            mg_set(MUTABLE_SV(ary));
 
        PL_delaymagic = 0;
diff --git a/pp_hot.c b/pp_hot.c
index a8c06b8..1a7c13f 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1041,20 +1041,14 @@ PP(pp_aassign)
                *(relem++) = sv;
                didstore = av_store(ary,i++,sv);
                if (magic) {
-                   if (SvSMAGICAL(sv)) {
-                       /* More magic can happen in the mg_set callback, so we
-                        * backup the delaymagic for now. */
-                       U16 dmbak = PL_delaymagic;
-                       PL_delaymagic = 0;
+                   if (SvSMAGICAL(sv))
                        mg_set(sv);
-                       PL_delaymagic = dmbak;
-                   }
                    if (!didstore)
                        sv_2mortal(sv);
                }
                TAINT_NOT;
            }
-           if (PL_delaymagic & DM_ARRAY)
+           if (PL_delaymagic & DM_ARRAY_ISA)
                SvSETMAGIC(MUTABLE_SV(ary));
            break;
        case SVt_PVHV: {                                /* normal hash */
@@ -1078,12 +1072,8 @@ PP(pp_aassign)
                        duplicates += 2;
                    didstore = hv_store_ent(hash,sv,tmpstr,0);
                    if (magic) {
-                       if (SvSMAGICAL(tmpstr)) {
-                           U16 dmbak = PL_delaymagic;
-                           PL_delaymagic = 0;
+                       if (SvSMAGICAL(tmpstr))
                            mg_set(tmpstr);
-                           PL_delaymagic = dmbak;
-                       }
                        if (!didstore)
                            sv_2mortal(tmpstr);
                    }
@@ -1107,13 +1097,7 @@ PP(pp_aassign)
            }
            else
                sv_setsv(sv, &PL_sv_undef);
-
-           if (SvSMAGICAL(sv)) {
-               U16 dmbak = PL_delaymagic;
-               PL_delaymagic = 0;
-               mg_set(sv);
-               PL_delaymagic = dmbak;
-           }
+           SvSETMAGIC(sv);
            break;
        }
     }
diff --git a/t/op/tie.t b/t/op/tie.t
index 281c0d9..ad3031a 100644
--- a/t/op/tie.t
+++ b/t/op/tie.t
@@ -897,3 +897,19 @@ fetching... *{}
 fetching... @{}
 fetching... %{}
 fetching... ${}
+########
+# RT 51636: segmentation fault with array ties
+
+tie my @a, 'T';
+...@a = (1);
+print "ok\n"; # if we got here we didn't crash
+
+package T;
+
+sub TIEARRAY { bless {} }
+sub STORE    { tie my @b, 'T' }
+sub CLEAR    { }
+sub EXTEND   { }
+
+EXPECT
+ok

--
Perl5 Master Repository

Reply via email to