[perl] Do not leak with attribute on my variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



commit f0eaa7691d946c2a03220a8a38210455b59d0f32
Author: Petr Písař <ppisar@xxxxxxxxxx>
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                                          |   10 +++-
 2 files changed, 86 insertions(+), 1 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@xxxxxxxx>
+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@xxxxxxxx>
+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,@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 b03d25a..c901b53 100644
--- a/perl.spec
+++ b/perl.spec
@@ -29,7 +29,7 @@
 Name:           perl
 Version:        %{perl_version}
 # release number must be even higher, because dual-lived modules will be broken otherwise
-Release:        237%{?dist}
+Release:        238%{?dist}
 Epoch:          %{perl_epoch}
 Summary:        Practical Extraction and Report Language
 Group:          Development/Languages
@@ -98,6 +98,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
@@ -1358,6 +1361,7 @@ tarball from perl.org.
 %patch13 -p1
 %patch14 -p1
 %patch15 -p1
+%patch16 -p1
 
 #copy the example script
 cp -a %{SOURCE5} .
@@ -1565,6 +1569,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
@@ -2709,6 +2714,9 @@ sed \
 
 # Old changelog entries are preserved in CVS.
 %changelog
+* Fri Sep 21 2012 Petr Pisar <ppisar@xxxxxxxxxx> - 4:5.16.1-238
+- Do not leak with attribute on my variable (bug #858966)
+
 * Thu Sep 20 2012 Petr Pisar <ppisar@xxxxxxxxxx> - 4:5.16.1-237
 - Put perl-podlators into perl-core list (bug #856516)
 
--
Fedora Extras Perl SIG
http://www.fedoraproject.org/wiki/Extras/SIGs/Perl
perl-devel mailing list
perl-devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/perl-devel



[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Legacy Announce]     [Fedora PHP Devel]     [Kernel Devel]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Big List of Linux Books]     [Gimp]     [Yosemite Information]
  Powered by Linux