New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak with use feature; and s///ee #9643
Comments
From cary.millsap@gmail.comCreated by cary.millsap@gmail.comThis is a bug report for perl from cary.millsap@gmail.com, ----------------------------------------------------------------- Here is a test case that reproduces a memory leak. Repro instructions are #!/usr/bin/perl # Demonstrate an apparent memory leak when using use feature qw(:5.10) with use strict; Perl Info
|
From p5p@perl.wizbit.be
Easier test script: #!/usr/bin/perl -l use strict; system("ps uh $$"); __END__ Two things affect the memory leak: (I also reproduced this on blead but the one that is tested is a Kind regards, Bram |
The RT System itself - Status changed from 'new' to 'open' |
From p5p@spam.wizbit.beOn Mon Feb 09 04:35:54 2009, p5p@perl.wizbit.be wrote:
Did a binary search: ----Program---- use strict; my for (0 .. 100_000) { my if ($mem2 > $mem1 + 2048) { ----Output of .../pjYRGC9/perl-5.9.3@27665/bin/perl---- ----EOF ($?='0')---- ----EOF ($?='0')---- http://public.activestate.com/cgi-bin/perlbrowse/p/27666 Change 27666 by nicholas@nicholas-saigo on 2006/04/01 21:17:46 Automatically set HINT_LOCALIZE_HH whenever %^H is modified. Kind regards, Bram |
From alex@chmrr.netAt Sun Feb 08 23:49:18 -0500 2009, Cary Millsap (via RT) wrote:
Fix is attached. |
From alex@chmrr.net0001-Fix-RT-63110-two-small-memory-leaks-were-introduced-.patchFrom a05e910190864dbe2c98bc149f6fc067c16072a6 Mon Sep 17 00:00:00 2001
From: Alex Vandiver <alexmv@mit.edu>
Date: Fri, 29 May 2009 20:17:36 -0400
Subject: [PATCH] Fix [RT#63110] -- two small memory leaks were introduced in 5b9c067
---
hv.c | 2 +-
pp_ctl.c | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/hv.c b/hv.c
index 1776053..2cefbcb 100644
--- a/hv.c
+++ b/hv.c
@@ -1444,7 +1444,7 @@ Perl_hv_copy_hints_hv(pTHX_ HV *const ohv)
while ((entry = hv_iternext_flags(ohv, 0))) {
SV *const sv = newSVsv(HeVAL(entry));
sv_magic(sv, NULL, PERL_MAGIC_hintselem,
- (char *)newSVhek (HeKEY_hek(entry)), HEf_SVKEY);
+ (char *)sv_2mortal(newSVhek (HeKEY_hek(entry))), HEf_SVKEY);
(void)hv_store_flags(hv, HeKEY(entry), HeKLEN(entry),
sv, HeHASH(entry), HeKFLAGS(entry));
}
diff --git a/pp_ctl.c b/pp_ctl.c
index b4f0ade..2c80627 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3636,8 +3636,11 @@ PP(pp_entereval)
SAVEDELETE(PL_defstash, safestr, len);
SAVEHINTS();
PL_hints = PL_op->op_targ;
- if (saved_hh)
+ if (saved_hh) {
+ /* SAVEHINTS created a new HV in PL_hintgv, which we need to GC */
+ SvREFCNT_dec(GvHV(PL_hintgv));
GvHV(PL_hintgv) = saved_hh;
+ }
SAVECOMPILEWARNINGS();
PL_compiling.cop_warnings = DUP_WARNINGS(PL_curcop->cop_warnings);
if (PL_compiling.cop_hints_hash) {
--
1.6.3.204.g8c948
|
@rgs - Status changed from 'open' to 'resolved' |
From p5p@perl.wizbit.beCiteren Rafael Garcia-Suarez <rgarciasuarez@gmail.com>:
Attached is a test case for this bug. I added the test in a new file t/lib/feature/leak because I could not Best regards, Bram |
From @rgs2009/5/31 Bram <p5p@perl.wizbit.be>:
It's technically not a feature.pm bug, but it's related to hints, |
From @jbenjorep5p@perl.wizbit.be (Bram) writes:
Thanks, applied as cda5e2e |
From @iabynOn Mon, Jul 20, 2009 at 09:52:40AM -0700, Josh ben Jore wrote:
That test had already been applied by Rafael (in a different form): commit fa13de9 Add regression test for [RT#63110] Affected files ... Differences ... Inline Patchdiff --git a/t/op/eval.t b/t/op/eval.t
index 23725d5..4c01434 100755
--- a/t/op/eval.t
+++ b/t/op/eval.t
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-print "1..98\n";
+print "1..99\n";
eval 'print "ok 1\n";';
@@ -539,10 +539,20 @@ END_EVAL_TEST
my $ok = runperl(progfile => $tempfile);
print "not " unless $ok;
print "ok $test # eval { 1 } completly resets \$@\n";
-
- $test++;
}
else {
print "ok $test # skipped - eval { 1 } completly resets \$@";
}
+$test++;
+# Test that "use feature" and other hint transmission in evals and s///ee
+# don't leak memory
+{
+ use feature qw(:5.10);
+ my $t;
+ my $s = "a";
+ $s =~ s/a/$t = \%^H; qq( qq() );/ee;
+ print "not " if Internals::SvREFCNT(%$t) != 1;
+ print "ok $test - RT 63110\n";
+ $test++;
+}
-- A major Starfleet emergency breaks out near the Enterprise, but |
From @jbenjoreOn Mon, Jul 20, 2009 at 9:52 AM, Josh ben Jore<twists@gmail.com> wrote:
Reverted as a5326e8 because Josh |
Migrated from rt.perl.org#63110 (status was 'resolved')
Searchable as RT63110$
The text was updated successfully, but these errors were encountered: