Bug#401132: Devel::Peek enhancement

Dominic Hargreaves dom at earth.li
Sun Aug 11 21:18:06 UTC 2013


On Fri, Jul 12, 2013 at 11:59:14PM +0100, Dominic Hargreaves wrote:
> On Wed, Jan 27, 2010 at 10:06:39AM -0800, Robert Stone wrote:
> > On Wed, Jan 27, 2010 at 12:31:44PM +0200, Niko Tyni wrote:
> > > 
> > > Sorry for the lack of action on this.
> > 
> > 	No problem at all, thanks for looking into this.
> > > 
> > > What's wrong with Devel::Peek:SvREFCNT(\%m) ?
> > 
> > 	"\%m" is a reference constructor, so SvREFCNT() ends up
> > reporting the reference count of that newly constructed SV.  The
> > situation can be illustrated with this small script:
> > 
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
> > use Devel::Peek;
> > my %m = (a => 'b');
> > my $mr = \%m;
> > Devel::Peek::Dump($mr);
> > print Devel::Peek::SvREFCNT(\%m), "\n";
> > 
> > 	From the Dump you can see that %m (the PVHV) has a refcount of
> > 2, but "Devel::Peek::SvREFCNT(\%m)" reports 1.  The reason for this can
> > be illustrated by breaking that call up a little bit.  One would
> > normally expect that:
> > 
> > Devel::Peek::SvREFCNT(\%m)
> > 
> > should be equivalent to
> > 
> > my $tmp = \%m;
> > Devel::Peek::SvREFCNT($tmp)
> > 
> > which unsurprisingly reports a refcount of 1 for $tmp.  Nothing changes
> > when $tmp is an immediate, unlabeled value on the argument stack to
> > SvREFCNT() and I think that's expected and correct behavior.
> > 
> > 	The proposed patch solves this difficulty by always passing the
> > argument from Perl by reference and then unconditionally dereferencing
> > to access the target value.
> 
> Hi Robert,
> 
> Sorry for the delay in pointing this, but I forwarded this to the
> upstream bug tracker and various people are discussing a fix.
> 
> https://rt.perl.org/rt3//Ticket/Display.html?id=117793

A fix for this has now been applied upstream:

http://perl5.git.perl.org/perl.git/commit/da1929e7566d4399b20541f8609bd48b40663034

As the bug is old and the severity is minor, I don't plan any backporting
work, but hopefully this will meet your needs when it makes it into 
Debian at some point?

Cheers,
Dominic.




More information about the Perl-maintainers mailing list