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 named regexp captures #10702
Comments
From r.khamidullin@transcredit.ruPlease, I have a memory leak. Sample with memory leak Sample without memory leak -- Characteristics of this binary (from libperl): -- Р���ам Хамид�ллин |
From @iabynOn Wed, Aug 18, 2010 at 04:36:10AM -0700, r.khamidullin wrote:
Can you please supply a short, complete program that demonstrates the -- |
The RT System itself - Status changed from 'new' to 'open' |
From @SBECK-githubCreated by @SBECK-githubThere is a memory leak in both perl 5.10 and 5.12 that occurs when named The following script illustrates the bug: ============================= $a1 = '(?<a>\d)'; $a2 = $a1; $b = '\d'; #$string = "12"; while (1) {
|
@iabyn - Status changed from 'open' to 'stalled' |
From @SBECK-githubJust FYI, I just checked this against perl 5.14.1 and 5.15.0 and the |
@SBECK-github - Status changed from 'new' to 'open' |
From @pluI think I'm experiencing the same bug. I've narrowed it down to a simple |
From [Unknown Contact. See original ticket]I think I'm experiencing the same bug. I've narrowed it down to a simple |
From @pluChanging status from stalled to open, hope that's ok. If not, just |
@cpansprout - Status changed from 'stalled' to 'open' |
From data@cpan.orgYou may want to merge #77304 into this one, since they are the same. Or On Thu Oct 07 04:40:37 2010, sbeck wrote:
PATH=/home/sulbeck/local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/bin:/sbin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin:/etc:.
multi:/home/sulbeck/local/lib/perl5/site_perl/5.12.1:/home/sulbeck/local/lib/perl5/site_perl:/home/sulbeck/local/lib/perl5/5.12.1/x86_64-
multi:/home/sulbeck/local/lib/perl5/5.12.1:/usr/lib/perl5/site_perl/5.12.1/x86_64-
multi:/usr/lib/perl5/site_perl/5.12.1:/usr/lib/perl5/vendor_perl/5.12.1/x86_64-
|
From @pluAttached a fix. Please review that patch. I have to admit to I have no experience at all |
From @plu0001-Fix-78266-Memory-leak-with-named-regexp-captures.patchFrom f753a93ee39594777931d507a8acbcab61183436 Mon Sep 17 00:00:00 2001
From: Johannes Plunien <plu@pqpq.de>
Date: Tue, 13 Dec 2011 11:39:52 +0400
Subject: [PATCH] Fix #78266: Memory leak with named regexp captures.
---
regcomp.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/regcomp.c b/regcomp.c
index b1b8e6f..9e9fac4 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5418,6 +5418,10 @@ Perl_reg_named_buff_fetch(pTHX_ REGEXP * const r, SV * const namesv,
return newRV_noinc(MUTABLE_SV(retarray));
}
}
+
+ if (ret)
+ SvREFCNT_dec(ret);
+
return NULL;
}
--
1.7.7
|
From @pluAdded a testcase. |
From @plu0002-Add-testcase-for-78266.patchFrom 7d77e85aabc4cf50f733820cb2b793ffc240840c Mon Sep 17 00:00:00 2001
From: Johannes Plunien <plu@pqpq.de>
Date: Tue, 13 Dec 2011 12:29:47 +0400
Subject: [PATCH 2/2] Add testcase for #78266.
---
t/op/svleak.t | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/t/op/svleak.t b/t/op/svleak.t
index 5eb090c..4eee3c8 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 => 19;
+plan tests => 20;
# 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
@@ -141,3 +141,20 @@ leak(2, 0,
},
"rcatline leak"
);
+
+{
+ my $RE = qr/
+ (?:
+ <(?<tag>
+ \s*
+ [^>\s]+
+ )>
+ )??
+ /xis;
+
+ "<html><body></body></html>" =~ m/$RE/gcs;
+
+ leak(5, 0, sub {
+ my $tag = $+{tag};
+ }, "named regexp captures");
+}
--
1.7.7
|
From @cpansproutOn Tue Dec 13 00:09:08 2011, plu wrote:
This patch looks correct to me, so I have applied it as b28f4af. -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'resolved' |
From @cpansproutOn Tue Dec 13 00:31:24 2011, plu wrote:
And this one as a17b855. -- Father Chrysostomos |
From @avarOn Tue, Dec 13, 2011 at 18:32, Father Chrysostomos via RT
I had already pushed smoke-me/avar-plu-RT-78266 earlier today as In this case we're leaking memory because we're allocating something, I've pushed a better fix to blead in |
From @demerphqOn 13 December 2011 19:11, �var Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Concur that this is a better fix. This one was my fault. Sorry people. Yves -- |
From r.khamidullin@transcredit.ruJohannes Plunien, Thank You very much. I can not check that fix at the moment. 13.12.2011 12:09, Johannes Plunien via RT пи�е�:
-- Р���ам Хамид�ллин |
From r.khamidullin@transcredit.ruJohannes Plunien, full job. :) Regards! 13.12.2011 12:31, Johannes Plunien via RT пи�е�:
-- Р���ам Хамид�ллин |
Migrated from rt.perl.org#78266 (status was 'resolved')
Searchable as RT78266$
The text was updated successfully, but these errors were encountered: