develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #79824] hash value sharing breakage

Thread Previous
From:
Father Chrysostomos via RT
Date:
January 7, 2012 17:01
Subject:
[perl #79824] hash value sharing breakage
Message ID:
rt-3.6.HEAD-14510-1325984467-908.79824-15-0@perl.org
On Fri Jan 06 23:54:01 2012, sprout wrote:
> On Fri Nov 26 08:20:26 2010, zefram@fysh.org wrote:
> > Now, another complication.  My real code behind this actually isn't
> > calling Encode::_utf8_on().  It's XS code, and it's doing SvUTF8_on()
> > on an sv_mortalcopy() of the original key.  If I change
> >    sv_mortalcopy()
> > to sv_2mortal(newSVsv()) then the problem goes away.  This seems
> >    strange,
> > since both sv_mortalcopy() and newSVsv() claim (in perlapi(1)) to
> >    perform
> > their copying via sv_setsv().
> 
> I can tell you what the code is actually doing:
> 
> sv_setsv is a macro wrapper around sv_setsv_flags, which will allow
> COWing if PERL_CORE is defined, but not otherwise.
> 
> sv_mortalcopy is in core, so it COWs.
> 
> newSVsv calls sv_setsv_flags, but without the SV_DO_COW_SVSETSV flag. 
> It seems like an omission to me.  But putting the flag there would break
> XS code.
> 
> Maybe sv_mortalcopy should be modified not to trigger COWing.  Maybe we
> need to make it a macro around sv_mortalcopy_flags or some such, that
> does the same conditional flag application based on PERL_CORE.
> 
> What does Nicholas Clark think?
> 

This comment in pp_aassign is interesting:

		/* Specifically *not* sv_mortalcopy(), as that will steal TEMPs,
		   and we need a second copy of a temp here.  */


-- 

Father Chrysostomos


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

Thread Previous


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