[perl/f18] Do not leak with attribute on my variable

Petr Pisar ppisar at fedoraproject.org
Fri Sep 21 09:53:14 UTC 2012


commit 5a47098d553f0ed7edc0b45da4bd7275f2c2e790
Author: Petr Písař <ppisar at redhat.com>
Date:   Fri Sep 21 10:03:38 2012 +0200

    Do not leak with attribute on my variable

 ...4764-Stop-my-vars-with-attrs-from-leaking.patch |   77 ++++++++++++++++++++
 perl.spec                                          |    6 ++
 2 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/perl-5.16.1-perl-114764-Stop-my-vars-with-attrs-from-leaking.patch b/perl-5.16.1-perl-114764-Stop-my-vars-with-attrs-from-leaking.patch
new file mode 100644
index 0000000..78515ef
--- /dev/null
+++ b/perl-5.16.1-perl-114764-Stop-my-vars-with-attrs-from-leaking.patch
@@ -0,0 +1,77 @@
+From 13f27cb3dee86772eeed5d7d9b47746395ee603c Mon Sep 17 00:00:00 2001
+From: Father Chrysostomos <sprout at cpan.org>
+Date: Wed, 19 Sep 2012 21:53:51 -0700
+Subject: [PATCH] Stop my vars with attrs from leaking
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Ported to 5.16.1:
+
+commit 9fa29fa7929b4167c5491b792c5cc7e4365a2839
+Author: Father Chrysostomos <sprout at cpan.org>
+Date:   Wed Sep 19 21:53:51 2012 -0700
+
+    [perl #114764] Stop my vars with attrs from leaking
+
+S_apply_attrs was creating a SV containing a stash name, that was
+later to be put in a const op, which would take care of freeing it.
+But it didn’t free it for a my variable, because the branch where that
+const op was created didn’t apply.  So move the creation of that SV
+inside the branch that uses it, otherwise it leaks.  This leak was the
+result of commit 95f0a2f1ffc6.
+---
+ op.c          | 4 ++--
+ t/op/svleak.t | 5 ++++-
+ 2 files changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/op.c b/op.c
+index 24d5ecb..017580d 100644
+--- a/op.c
++++ b/op.c
+@@ -2279,13 +2279,11 @@ STATIC void
+ S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs, bool for_my)
+ {
+     dVAR;
+-    SV *stashsv;
+ 
+     PERL_ARGS_ASSERT_APPLY_ATTRS;
+ 
+     /* fake up C<use attributes $pkg,$rv, at attrs> */
+     ENTER;		/* need to protect against side-effects of 'use' */
+-    stashsv = stash ? newSVhek(HvNAME_HEK(stash)) : &PL_sv_no;
+ 
+ #define ATTRSMODULE "attributes"
+ #define ATTRSMODULE_PM "attributes.pm"
+@@ -2300,6 +2298,8 @@ S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs, bool for_my)
+ 			     newSVpvs(ATTRSMODULE), NULL);
+     }
+     else {
++	SV * const stashsv =
++	    stash ? newSVhek(HvNAME_HEK(stash)) : &PL_sv_no;
+ 	Perl_load_module(aTHX_ PERL_LOADMOD_IMPORT_OPS,
+ 			 newSVpvs(ATTRSMODULE),
+ 			 NULL,
+diff --git a/t/op/svleak.t b/t/op/svleak.t
+index df10953..6cfee2e 100644
+--- a/t/op/svleak.t
++++ b/t/op/svleak.t
+@@ -13,7 +13,7 @@ BEGIN {
+ 	or skip_all("XS::APItest not available");
+ }
+ 
+-plan tests => 21;
++plan tests => 22;
+ 
+ # run some code N times. If the number of SVs at the end of loop N is
+ # greater than (N-1)*delta at the end of loop 1, we've got a leak
+@@ -160,3 +160,6 @@ leak(2, 0,
+ }
+ 
+ leak(2,0,sub { !$^V }, '[perl #109762] version object in boolean context');
++
++# [perl #114764] Attributes leak scalars
++leak(2, 0, sub { eval 'my $x : shared' }, 'my $x :shared used to leak');
+-- 
+1.7.11.4
+
diff --git a/perl.spec b/perl.spec
index 7d4482d..033a4a0 100644
--- a/perl.spec
+++ b/perl.spec
@@ -95,6 +95,9 @@ Patch14:        perl-5.16.1-perl-113980-pp_syscall-I32-retval-truncates-the-retu
 # podlators-2.4.1
 Patch15:        perl-5.14.2-Override-the-Pod-Simple-parse_file.patch
 
+# Do not leak with attribute on my variable, rhbz#858966, RT#114764,
+# fixed after 5.17.4
+Patch16:        perl-5.16.1-perl-114764-Stop-my-vars-with-attrs-from-leaking.patch
 
 # Update some of the bundled modules
 # see http://fedoraproject.org/wiki/Perl/perl.spec for instructions
@@ -1317,6 +1320,7 @@ tarball from perl.org.
 %patch13 -p1
 %patch14 -p1
 %patch15 -p1
+%patch16 -p1
 
 #copy the example script
 cp -a %{SOURCE5} .
@@ -1524,6 +1528,7 @@ pushd %{build_archlib}/CORE/
     'Fedora Patch13: Clear $@ before "do" I/O error (RT#113730)' \
     'Fedora Patch14: Do not truncate syscall() return value to 32 bits (RT#113980)' \
     'Fedora Patch15: Override the Pod::Simple::parse_file (CPANRT#77530)' \
+    'Fedora Patch16: Do not leak with attribute on my variable (RT#114764)' \
     %{nil}
 
 rm patchlevel.bak
@@ -2595,6 +2600,7 @@ sed \
 %changelog
 * Fri Sep 21 2012 Petr Pisar <ppisar at redhat.com> - 4:5.16.1-232
 - perl-PathTools uses Carp
+- Do not leak with attribute on my variable (bug #858966)
 
 * Fri Sep 14 2012 Petr Pisar <ppisar at redhat.com> - 4:5.16.1-231
 - Override the Pod::Simple::parse_file to set output to STDOUT by default


More information about the scm-commits mailing list