develooper Front page | perl.perl5.porters | Postings from July 2013

[perl #119049] referencing some variables hides others from PadWalker starting 5.17.2

Thread Next
From:
Father Chrysostomos via RT
Date:
July 28, 2013 07:19
Subject:
[perl #119049] referencing some variables hides others from PadWalker starting 5.17.2
Message ID:
rt-3.6.HEAD-2552-1374995970-1742.119049-15-0@perl.org
On Sat Jul 27 17:05:39 2013, rjbs wrote:
> I received a user report along with an excellent reproducer, here
>    converted to a test:
> 
>     use PadWalker 'peek_my';
>     use Test::More;
> 
>     my ($var1, $var2, $var3);
> 
>     our $want = { map {; $_ => \undef } qw($var1 $var2 $var3) };
> 
>            sub { is_deeply( peek_my(0), $want, 'anon A' );       }-
>    >();

That one is not a closure.  It passes (serendipitously).

>            sub { is_deeply( peek_my(0), $want, 'anon B' ); $var2 }-
>    >();

That one is.  It fails.

It was probably a0d2bbd5c470 that did it.  See #89544.

PadWalker simply follows CvOUTSIDE pointers.  The problem with a closure
clone having an outside pointer is that it has to be reference-counted,
easily resulting in circularities.

We must retain the CvOUTSIDE pointer for string eval to be able to look
up variables in the parent.  But in the absence of string eval or s///ee
we try to avoid memory leaks.  Also, try running it under the debugger.
 It passes.

I do not consider this a bug, because the closure does not close over
$var1 or $var3.  Those variables may already have been freed by the time
you call peek_my.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=119049

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About