On Sat Dec 24 15:55:23 2011, ikegami@adaelis.com wrote: > 2011/12/22 Olivier Mengu� <perlbug-followup@perl.org> > > > # New Ticket Created by Olivier Mengu� > > # Please include the string: [perl #106864] > > # in the subject line of all future correspondence about this issue. > > # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=106864 > > > > > > > This is a bug report for perl from dolmen@cpan.org, > > generated with the help of perlbug 1.39 running under perl 5.10.1. > > > > > > ----------------------------------------------------------------- > > > > > > With the following expression: > > > > my $x = sub { }; > > > > the refcount of $x is 2 instead of 1. > > There is no such problem if the sub, instead of behind a simple sub, > > is a closure. > > > > >perl -MDevel::Peek -e"for (1..3) { push @a, sub {}; } Dump($a[0]);" > SV = IV(0x57b650) at 0x57b654 > REFCNT = 1 > FLAGS = (ROK) > RV = 0x57b624 > SV = PVCV(0x4a9dd4) at 0x57b624 > REFCNT = 4 > FLAGS = (PADMY,ANON,WEAKOUTSIDE,CVGV_RC) > COMP_STASH = 0x57b444 "main" > START = 0x4d2cb8 ===> 0 > ROOT = 0x4d2c9c > GVGV::GV = 0x4a961c "main" :: "__ANON__" > FILE = "-e" > DEPTH = 0 > FLAGS = 0x490 > OUTSIDE_SEQ = 96 > PADLIST = 0x4a954c > PADNAME = 0x4a960c(0x4a12f4) PAD = 0x4a98fc(0x4a0c64) > OUTSIDE = 0x57b6b4 (MAIN) > > 4, one for each element in @a, and one to the sub alive until sub {} needs > it next. > > With closures, there would be 4 CVs with one reference each instead of 1 CV > with 4 reference. I think this is a bug, in that mentioning a variable in a sub shouldn’t change whether $x has the only reference after ‘$x = sub{}’. It also causes the blessing bug in ticket #3306. -- Father Chrysostomos --- via perlbug: queue: perl5 status: rejected https://rt.perl.org:443/rt3/Ticket/Display.html?id=106864Thread Previous | Thread Next