Change 35063 by [EMAIL PROTECTED] on 2008/12/09 16:57:07

        Integrate:
        [ 34209]
        [perl #56908] DBI memory leak in 5.10.0 due to change 26530
        
        A weakref to a HV would leak, because the xhv_backreferences
        array is created with a refcount of 2 (to avoid premature freeing
        during global destruction), but the RC was only decremented once
        when the parent HV was freed.
        Also, when thread cloned, the new array was being created with a
        RC of 1, rather than 2, which coincidentally worked due to the
        first bug.

Affected files ...

... //depot/maint-5.10/perl/hv.c#6 integrate
... //depot/maint-5.10/perl/sv.c#33 integrate

Differences ...

==== //depot/maint-5.10/perl/hv.c#6 (text) ====
Index: perl/hv.c
--- perl/hv.c#5~34599~  2008-10-26 14:44:48.000000000 -0700
+++ perl/hv.c   2008-12-09 08:57:07.000000000 -0800
@@ -1959,6 +1959,7 @@
     if (av) {
        HvAUX(hv)->xhv_backreferences = 0;
        Perl_sv_kill_backrefs(aTHX_ (SV*) hv, av);
+       SvREFCNT_dec(av);
     }
 }
 

==== //depot/maint-5.10/perl/sv.c#33 (text) ====
Index: perl/sv.c
--- perl/sv.c#32~35017~ 2008-12-04 17:54:55.000000000 -0800
+++ perl/sv.c   2008-12-09 08:57:07.000000000 -0800
@@ -10425,10 +10425,11 @@
                        daux->xhv_eiter = saux->xhv_eiter
                            ? he_dup(saux->xhv_eiter,
                                        (bool)!!HvSHAREKEYS(sstr), param) : 0;
+                       /* backref array needs refcnt=2; see sv_add_backref */
                        daux->xhv_backreferences =
                            saux->xhv_backreferences
                                ? (AV*) SvREFCNT_inc(
-                                       sv_dup((SV*)saux->xhv_backreferences, 
param))
+                                       
sv_dup_inc((SV*)saux->xhv_backreferences, param))
                                : 0;
 
                         daux->xhv_mro_meta = saux->xhv_mro_meta
End of Patch.

Reply via email to