develooper Front page | perl.perl5.porters | Postings from August 2001

[patch] rid "Scalars leaked" from perl_clone

Thread Next
From:
Doug MacEachern
Date:
August 4, 2001 10:46
Subject:
[patch] rid "Scalars leaked" from perl_clone
Message ID:
Pine.LNX.4.21.0108041031310.23972-100000@mako.covalent.net
"Scalars leaked" with perl_clone is trigged by constant
subroutines.  where the parent syntax tree is shared with an SV for each
constant sub.  patch below shuts up the warning, but is it safe for
interpreters to share these SVs?  cannot sv_dup(CvXSUBANY.any_ptr) since
the syntax tree is only destroyed once, so we'd end up with real leakage
and a pile more of "Scalars leaked".  if it is not safe to share these, i
see 2 options:
- PL_const_cv_padav similar to the regex pad, which seems like far too
much overhead when there option b ...
- revert to the 5.6.1 implementation of constant subs, which would use the
exist mechanism for managing SVOPs between interpreters

but i'm thinking (hoping) it is safe to share these SVs since they are
readonly.

Index: sv.c
===================================================================
RCS file: /usr/local/cvs_repository/perl-current-mirror/sv.c,v
retrieving revision 1.1.1.71
diff -u -r1.1.1.71 sv.c
--- sv.c	2001/08/04 15:52:10	1.1.1.71
+++ sv.c	2001/08/04 17:27:11
@@ -9090,6 +9090,10 @@
 	CvROOT(dstr)	= OpREFCNT_inc(CvROOT(sstr));
 	CvXSUB(dstr)	= CvXSUB(sstr);
 	CvXSUBANY(dstr)	= CvXSUBANY(sstr);
+	if (CvCONST(sstr)) {
+	    CvXSUBANY(dstr).any_ptr =
+                SvREFCNT_inc(CvXSUBANY(sstr).any_ptr);
+	}
 	CvGV(dstr)	= gv_dup(CvGV(sstr), param);
 	if (param->flags & CLONEf_COPY_STACKS) {
 	  CvDEPTH(dstr)	= CvDEPTH(sstr);


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About