> Please download, test, and report back on this release candiate.

Hi Fred (and hopefully the list),

as seen in <http://bugs.debian.org/650675>, we're seeing numerous lines of
 Attempt to free unreferenced scalar: SV 0x7f9c0c347490, Perl interpreter: 
0x7f9c0c1a2dd0 during global destruction.
on Debian unstable with 2.0.5 and Perl 5.14.2. I've been trying to get
patches through to the mod-perl dev list with no success; there seems
to be something broken with the list moderation. (I'd be happy to provide
message-ids and the like if somebody is interested, and they can also
be found in the bug log.)

I've verified that those still get emitted with 2.0.6 RC1. The
test suite passes, but 
 % grep unreferenced t/logs/error_log|wc -l
 30

This seems related to -Dusethreads and started with 5.13.6 or so; please see
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=650675#50
for the full analysis including the perl change that broke this.

Could you please consider these patches for 2.0.6, or let me know if
I've got it all wrong.

Thanks for your work,
-- 
Niko Tyni   nt...@debian.org
>From 2099956795016f3bd08768dda195aeec7dc2267b Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Wed, 14 Dec 2011 22:51:27 +0200
Subject: [PATCH] Fix a reference counting bug uncovered by Perl 5.13.6

As seen in
 http://bugs.debian.org/650675
 http://article.gmane.org/gmane.comp.apache.mod-perl.devel/9928

perl since 5.13.6 with -Dusethreads makes mod_perl2 issue warnings like

 Attempt to free unreferenced scalar: SV 0x7f9c0c347490, Perl interpreter: 0x7f9c0c1a2dd0 during global destruction.

on startup regardless of the Perl code executed.

The double-freed scalar is the CV pointer for ModPerl::Util::exit()
whose reference count wasn't increased properly.
---
 src/modules/perl/modperl_perl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/modules/perl/modperl_perl.c b/src/modules/perl/modperl_perl.c
index e992df4..1a2b3ce 100644
--- a/src/modules/perl/modperl_perl.c
+++ b/src/modules/perl/modperl_perl.c
@@ -55,7 +55,9 @@ void modperl_perl_core_global_init(pTHX)
 
     while (cglobals->name) {
         GV *gv = gv_fetchpv(cglobals->core_name, TRUE, SVt_PVCV);
-        GvCV_set(gv, get_cv(cglobals->sub_name, TRUE));
+        CV *cv = get_cv(cglobals->sub_name, TRUE);
+        GvCV_set(gv, cv);
+        SvREFCNT_inc(cv);
         GvIMPORTED_CV_on(gv);
         cglobals++;
     }
-- 
1.7.7.3

>From cbf08a2de6f967863d764eb0bc620178c4ed43fe Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Sat, 17 Dec 2011 09:16:22 +0200
Subject: [PATCH 2/2] Fix another reference counting bug uncovered by Perl
 5.13.6

As seen in
 http://bugs.debian.org/650675
 http://article.gmane.org/gmane.comp.apache.mod-perl.devel/9928

perl since 5.13.6 with -Dusethreads makes mod_perl2 issue warnings like

 Attempt to free unreferenced scalar: SV 0x7f9c0c347490, Perl interpreter: 0x7f9c0c1a2dd0 during global de
struction.

An earlier commit fixed some of these in modperl_perl_core_global_init(),
follow the suit with new_constsub().
---
 src/modules/perl/modperl_const.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/modules/perl/modperl_const.c b/src/modules/perl/modperl_const.c
index 8732d4f..39a3ec9 100644
--- a/src/modules/perl/modperl_const.c
+++ b/src/modules/perl/modperl_const.c
@@ -51,7 +51,9 @@ static void new_constsub(pTHX_ constants_lookup lookup,
             gv_init(alias, caller_stash, name, name_len, TRUE);
         }
 
-        GvCV_set(alias, GvCV(*gvp));
+        CV *cv = GvCV(*gvp);
+        GvCV_set(alias, cv);
+        SvREFCNT_inc(cv);
     }
 }
 
-- 
1.7.7.3

Reply via email to