-
Notifications
You must be signed in to change notification settings - Fork 565
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
$AUTOLOAD inside of sub AUTOLOAD{} appears to create a memory leak #11949
Comments
From jtbraun@CPAN.orgCreated by jtbraun@CPAN.orgThis is a bug report for perl from jtbraun@CPAN.org, ----------------------------------------------------------------- my $i = 0; my __END__ The above test eval's code of the form: package Acme::Test::Leak::namespace000001; Where namespace always increases, $VAR takes on the values OTHERVAR or delete $Acme::Test::Leak::{$subclass.'::'}; And then the test prints out the current process memory usage. This v:OTHERVAR s:OTHERSUB n: 50 :: 0.6 v:OTHERVAR s:AUTOLOAD n: 50 :: 0.6 v:AUTOLOAD s:OTHERSUB n: 50 :: 0.6 v:AUTOLOAD s:AUTOLOAD n: 50 :: 0.7 Perl Info
|
From @jkeenanOn Wed Feb 08 21:48:57 2012, jtbraun@CPAN.org wrote:
[snip]
I duplicated your results on Linux/i386. However, I could not run your ##### How should I modify the 'ps' line in your code for systems other than Linux? Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Sat Feb 11 08:26:56 2012, jkeenan wrote:
I modified it to print out the process number and go into an infinite warn $$; my $i = 0; This also shows that the problem is not specific to AUTOLOAD. But The body of the sub is referencing the *OTHERVAR glob, which references -- Father Chrysostomos |
From @demerphqOn 12 February 2012 23:51, Father Chrysostomos via RT
So you are saying that
produces a closure, but it should not, as $varname is a dynamic cheers -- |
From zefram@fysh.orgdemerphq wrote:
It's not a closure in the sense of lexical variables. It's a non-cloning
The scalar variable *is* looked up afresh every time. "local" can be used -zefram |
From @demerphqOn 13 February 2012 11:06, Zefram <zefram@fysh.org> wrote:
Then it is a closure on the glob. Which is wrong. It should look up
That may be, but that it does so is a bug. Consider the following evil script and how it behaves and how I think package Foo; sub AUTOLOAD { my $o= bless {}; $o->testing; my print $glob,"\n"; my $sub= *$glob{CODE}; if (0) { $o->testing_again; __END__ Can't locate object method "testing_again" via package "Foo" at - line 34. "Does work, but buggy" output: Orig AUTOLOAD: Foo::testing Expected output: Orig AUTOLOAD: Foo::testing -- |
From jtbraun@CPAN.orgOn 02/11/2012 08:26 AM, James E Keenan via RT wrote:
I'm afraid that I don't know the answer to your question. The 'ps' line Jeremy |
From @demerphqOn 12 February 2012 06:56, <jtbraun@cpan.org> wrote:
Digging further with a modified version of the original script using a I personally thought that ${"AUTOLOAD"} and ${AUTOLOAD} and $AUTOLOAD So there is a workaround for this. The question is whether or not it But for your case, generating code in Parse::RecDescent, it seems to Yves $ cat autoload_leak.pl; perl autoload_leak.pl my %seen; my v:OTHERVAR s:AUTOLOAD n: 50 :: 0.6 package Acme::Test::Leak::namespace000401; Acme::Test::Leak::namespace000401 => package Acme::Test::Leak::namespace000801; Acme::Test::Leak::namespace000801 => package Acme::Test::Leak::namespace001201; Acme::Test::Leak::namespace001201 => -- |
From @nwc10On Mon, Feb 13, 2012 at 12:53:08PM +0100, demerphq wrote:
To clarify, when you write ${"AUTOLOAD"} you mean that syntax with a
I understand why this is a difference. I also understand what the I guess it comes down to the problem that Perl 5 isn't so much a design Nicholas Clark |
From @demerphqOn 13 February 2012 13:04, Nicholas Clark <nick@ccl4.org> wrote:
Yes, that syntax with a string constant. I thought that ${foo} was
To me, this feels like an optimisation gotchya, meaning that at
I guess this is the kind of thing that probably Larry should decide on. I can't help but wonder if the answer to this could have deeper cheers, -- |
From zefram@fysh.orgdemerphq wrote:
To be clear, I think $foo doing glob lookup at compile time is not-a-bug, -zefram |
From @nwc10On Mon, Feb 13, 2012 at 01:15:41PM +0100, demerphq wrote:
I don't think it ever has. $ ./perl -Ilib -le '$foo = "old"; sub p {print $ ~/Sandpit/5000/bin/perl -le '$foo = "old"; sub p {print $ /usr/local/perl4/bin/perl4.036 -le '$foo = "old"; sub p {print $foo;} &p; delete $_main{"foo"}; eval q{$foo = "new"; print $foo}; &p' And you learn something new (or old, or obsolete), every day. Perl 4: The symbol table for a package happens to be stored in the associative
Larry eliminated typeglobs very early in the design of Perl 6. That comment might seem at first reading to be an irrelevant or facetious Nicholas Clark |
From @cpansproutOn Mon Feb 13 03:53:42 2012, demerphq wrote:
There are at least half a dozen CPAN modules that rely on op-to-glob -- Father Chrysostomos |
From jtbraun@theweirdhotel.netYes, I can use the workaround. Thank you all very much. Jeremy On Feb 13, 2012, at 3:53 AM, demerphq <demerphq@gmail.com> wrote:
|
From @cpansproutOn Mon Feb 13 06:07:06 2012, zefram@fysh.org wrote:
I’ll mark it as such, then. -- Father Chrysostomos |
From [Unknown Contact. See original ticket]On Mon Feb 13 06:07:06 2012, zefram@fysh.org wrote:
I’ll mark it as such, then. -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#110248 (status was 'rejected')
Searchable as RT110248$
The text was updated successfully, but these errors were encountered: