From d99b02a1a9949639f16470065ea5568cd92f788d Mon Sep 17 00:00:00 2001 From: Dave Mitchell Date: Thu, 3 Jul 2003 02:32:11 +0100 Subject: [PATCH] Re: ext/List/Util/t/weak.t panic Message-ID: <20030703003211.GB3747@fdgroup.com> p4raw-id: //depot/perl@19943 --- mg.c | 1 + sv.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mg.c b/mg.c index 1990b96..b69da05 100644 --- a/mg.c +++ b/mg.c @@ -1881,6 +1881,7 @@ Perl_magic_killbackrefs(pTHX_ SV *sv, MAGIC *mg) } i--; } + SvREFCNT_dec(av); /* remove extra count added by sv_add_backref() */ return 0; } diff --git a/sv.c b/sv.c index 69fbbaa..76b1403 100644 --- a/sv.c +++ b/sv.c @@ -5091,7 +5091,9 @@ S_sv_add_backref(pTHX_ SV *tsv, SV *sv) else { av = newAV(); sv_magic(tsv, (SV*)av, PERL_MAGIC_backref, NULL, 0); - SvREFCNT_dec(av); /* for sv_magic */ + /* av now has a refcnt of 2, which avoids it getting freed + * before us during global cleanup. The extra ref is removed + * by magic_killbackrefs() when tsv is being freed */ } if (AvFILLp(av) >= AvMAX(av)) { SV **svp = AvARRAY(av); -- 2.7.4