Author: torsten
Date: Tue Feb 14 19:29:11 2012
New Revision: 1244184

URL: http://svn.apache.org/viewvc?rev=1244184&view=rev
Log:
Fix 2 SV REFCNT bugs:

- modperl_perl_core_global_init(), the aliasing GV references the aliased
  CV. Thus, it should increment the REFCNT.
- new_constsub() in modperl_const.c, same story.

The bug has been there for years. Only starting with perl 5.14 it became
visible by messages like this in the error_log:

  Attempt to free unreferenced scalar: SV 0x7fc218, 
      Perl interpreter: 0x7cfdb0 during global destruction.

Modified:
    perl/modperl/trunk/Changes
    perl/modperl/trunk/src/modules/perl/modperl_const.c
    perl/modperl/trunk/src/modules/perl/modperl_perl.c

Modified: perl/modperl/trunk/Changes
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/Changes?rev=1244184&r1=1244183&r2=1244184&view=diff
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Tue Feb 14 19:29:11 2012
@@ -12,6 +12,10 @@ Also refer to the Apache::Test changes l
 
 =item 2.0.6-dev
 
+Fix a few REFCNT bugs.
+Patch submitted by: Niko Tyni <nt...@debian.org>
+Reviewed by: Torsten Foertsch
+
 Correct the initialization of the build config in ModPerl::MM. The global
 variable was only being set once on loading the module, which was before
 Apache2::BuildConfig.pm had been written, leading to cwd and MP_LIBNAME

Modified: perl/modperl/trunk/src/modules/perl/modperl_const.c
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_const.c?rev=1244184&r1=1244183&r2=1244184&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_const.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_const.c Tue Feb 14 19:29:11 2012
@@ -51,7 +51,7 @@ static void new_constsub(pTHX_ constants
             gv_init(alias, caller_stash, name, name_len, TRUE);
         }
 
-        GvCV_set(alias, GvCV(*gvp));
+        GvCV_set(alias, MUTABLE_CV(SvREFCNT_inc(GvCV(*gvp))));
     }
 }
 

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl.c
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl.c?rev=1244184&r1=1244183&r2=1244184&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl.c Tue Feb 14 19:29:11 2012
@@ -55,7 +55,8 @@ 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));
+        GvCV_set(gv,
+                 MUTABLE_CV(SvREFCNT_inc(get_cv(cglobals->sub_name, TRUE))));
         GvIMPORTED_CV_on(gv);
         cglobals++;
     }


Reply via email to