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

[perl #78194] Referencing a PADTMP twice produces two copies

Thread Previous | Thread Next
Father Chrysostomos via RT
August 13, 2013 20:46
[perl #78194] Referencing a PADTMP twice produces two copies
Message ID:
On Mon Aug 12 02:00:18 2013, sprout wrote:
> On Sat Jul 27 11:27:57 2013, sprout wrote:
> > I did not fix this bug for calls to XSUBs, because it will make
> > Devel::Peek less useful.  Calling Dump("$x") and being able to see what
> > pp_stringify is return[ing] is a useful feature.
> > 
> > (Here I’m referring to the original bug reported, not the newRV issue. 
> > Calling foo("$x") allowed the foo sub to see a TARG in $_[0], such that
> > print \$_[0], \$_[0] would show two different addresses.)
> > 
> > Currently foo("$x") will make a COW copy of the TARG if it is a Perl
> > sub, but pass the TARG itself if it is an XSUB.  So for XS code to call
> > newRV on that is wrong (or what newRV does is wrong).
> > 
> > I think the real solution here is to apply the fix to XSUBs (copy TARG
> > arguments) but modify Devel::Peek to inline itself, so that it remains
> > exempt.
> > 
> > That way the only XS code having access to TARGs will be that which
> > rummages through pads.  For most XS code this will just dwim.

I have made that change in commit 3455055.

> > 
> > In fact, having Devel::Peek inline itself would be useful for seeing the
> > return value of substr and vec in rvalue context, something currently
> > not possible.
> Attached is a patch to get Devel::Peek to inline itself.  It also allows
> Dump %hash and Dump @array.

And I applied that patch, with a slight tweak (with one arg it was
leaking ops), as 34b94bc4d.


Father Chrysostomos

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About