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? -- Father Chrysostomos --- via perlbug: queue: perl5 status: new https://rt.perl.org:443/rt3/Ticket/Display.html?id=79824Thread Next