On 16 March 2014 11:56, demerphq <demerphq@gmail.com> wrote:
Show quoted text> On 15 March 2014 16:53, Zefram via RT <bug-Sereal-Encoder@rt.cpan.org> wrote:
>> Sat Mar 15 11:53:24 2014: Request 93888 was acted upon.
>> Transaction: Ticket created by zefram@fysh.org
>> Queue: Sereal-Encoder
>> Subject: doesn't preserve special SV identity
>> Broken in: (no value)
>> Severity: (no value)
>> Owner: Nobody
>> Requestors: zefram@fysh.org
>> Status: new
>> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=93888 >
>>
>>
>> There are some special standard SVs that can be readily referenced
>> by Perl code, and so can be readily distinguished from ordinary SVs
>> that have the same value. Sereal doesn't preserve their identities.
>> It arguably should. Demonstration program attached.
>
> We have tags for undef/true/false, and code for detecting them,
> however as you observe it does not work very well.
>
> When I did the initial implementation of these I ran into this problem
> and filed a perlbug: perl #114838
>
https://rt.perl.org:443/rt3/Ticket/Display.html?id=114838
>
> I will poke into this, but further investigation from you would be helpful.
>
> The existing logic for handling this in srl_encoder.c at line 1353:
This turns out to be a decoder issue. I can fix the decoder so it
passes 5 of your six tests, one however does not pass
\do { my $z = undef },
Which fails because perl says "not-special" and Sereal starts saying "undef".
I think there is a conceptual problem with undef. We have the tag
SRL_HDR_UNDEF which is used to represent any undef var, including true
PL_sv_undef. If we want to track PL_sv_undef properly I think we have
to introduce a new tag, SRL_HDR_PERL_UNDEF, which would be used when
it really is PL_sv_undef.
I am not sure that this is worth it. So I am inclined to keep this
behavior for TRUE/FALSE, but not keep it for UNDEF.
The patch with one failing test is in the custom_op branch as:
commit b4ed5b29aba568ec0bde310eed2afcf3e56811a1
Author: Yves Orton <yves.orton@booking.com>
Date: Sun Mar 16 12:48:00 2014 +0100
fix [rt.cpan.org #93888] does not preserve special SV identity
Includes one failing test for SRL_HDR_UNDEF related to \do{my $x= undef}
which suggests we may have to undo the UNDEF part of this patch and live
with the fact that we dont round trip \undef properly, or we have to
patch the protocol to support it (boo)
--
perl -Mre=debug -e "/just|another|perl|hacker/"