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

[perl #79824] hash value sharing breakage

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
October 5, 2012 15:58
Subject:
[perl #79824] hash value sharing breakage
Message ID:
rt-3.6.HEAD-11172-1349477876-432.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.

Done with commit 108cb98.

-- 

Father Chrysostomos


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

Thread Previous | 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