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

[patch] rid "Scalars leaked" from perl_clone

Thread Next
Doug MacEachern
August 4, 2001 10:46
[patch] rid "Scalars leaked" from perl_clone
Message ID:
"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

Index: sv.c
RCS file: /usr/local/cvs_repository/perl-current-mirror/sv.c,v
retrieving revision
diff -u -r1.1.1.71 sv.c
--- sv.c	2001/08/04 15:52:10
+++ 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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About