Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Sereal-Encoder CPAN distribution.

Report information
The Basics
Id: 101878
Status: open
Priority: 0/
Queue: Sereal-Encoder

People
Owner: Nobody in particular
Requestors: zefram [...] fysh.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: blessedness lost from unreferenced scalars
Date: Mon, 2 Feb 2015 14:33:02 +0000
To: bug-Sereal-Encoder [...] rt.cpan.org
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 789b
$ perl -MSereal::Encoder=encode_sereal -MSereal::Decoder=decode_sereal -MData::Dumper=Dumper -we '@a=(3); bless \$a[0], "Foo"; print Dumper \$a[0]; print Dumper \decode_sereal(encode_sereal(\@a))->[0]' $VAR1 = bless( do{\(my $o = 3)}, 'Foo' ); $VAR1 = \3; $a[0] is blessed, but the serialisation of @a didn't preserve the blessedness. I suspect that underneath this there's some confusion about how blessing works: although blessing is always performed through a reference, and blessed objects are always handled through references, the status of being blessed is a property of the referenced object, not of the reference itself. I don't have any real code that's misbehaving due to this. It's an artificial test case that I came up with after reading the Sereal format spec. -zefram
Subject: Re: [rt.cpan.org #101878] blessedness lost from unreferenced scalars
Date: Mon, 2 Feb 2015 16:02:26 +0100
To: bug-Sereal-Encoder [...] rt.cpan.org
From: demerphq <demerphq [...] gmail.com>
Download (untitled) / with headers
text/plain 1.4k
On 2 February 2015 at 15:33, Zefram via RT <bug-Sereal-Encoder@rt.cpan.org> wrote: Show quoted text
> Mon Feb 02 09:33:13 2015: Request 101878 was acted upon. > Transaction: Ticket created by zefram@fysh.org > Queue: Sereal-Encoder > Subject: blessedness lost from unreferenced scalars > 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=101878 > > > > $ perl -MSereal::Encoder=encode_sereal -MSereal::Decoder=decode_sereal -MData::Dumper=Dumper -we '@a=(3); bless \$a[0], "Foo"; print Dumper \$a[0]; print Dumper \decode_sereal(encode_sereal(\@a))->[0]' > $VAR1 = bless( do{\(my $o = 3)}, 'Foo' ); > $VAR1 = \3; > > $a[0] is blessed, but the serialisation of @a didn't preserve the > blessedness. I suspect that underneath this there's some confusion > about how blessing works: although blessing is always performed through > a reference, and blessed objects are always handled through references, > the status of being blessed is a property of the referenced object, > not of the reference itself. > > I don't have any real code that's misbehaving due to this. It's an > artificial test case that I came up with after reading the Sereal > format spec.
Good catch. Thanks. I will think about what to do about this. We have a related issue with ties that we need to address. Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"
Subject: Re: [rt.cpan.org #101878] blessedness lost from unreferenced scalars
Date: Tue, 3 Feb 2015 11:17:38 +0000
To: demerphq via RT <bug-Sereal-Encoder [...] rt.cpan.org>
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 1.2k
A variation: $ perl -MSereal::Encoder=encode_sereal -MSereal::Decoder=decode_sereal -MData::Dumper=Dumper -we '@a=(0,3); $a[0] = \$a[1]; bless \$a[1], "Foo"; print Dumper $a[0]; print Dumper decode_sereal(encode_sereal(\@a))->[0]' $VAR1 = bless( do{\(my $o = 3)}, 'Foo' ); $VAR1 = bless( do{\(my $o = 3)}, 'Foo' ); $ perl -MSereal::Encoder=encode_sereal -MSereal::Decoder=decode_sereal -MData::Dumper=Dumper -we '@a=(3,0); $a[1] = \$a[0]; bless \$a[0], "Foo"; print Dumper $a[1]; print Dumper decode_sereal(encode_sereal(\@a))->[1]' $VAR1 = bless( do{\(my $o = 3)}, 'Foo' ); $VAR1 = \3; Sereal gets the aliasing within the array right in both cases, but whether the blessedness is preserved depends on the order in which the blessed scalar and the reference appear in the array. If the reference comes first then the blessedness is preserved; if the blessed scalar comes first then it is not. Amusingly, if you use Data::Dumper to display the whole array before encoding (print Dumper \@a), it can also fail to show the blessedness, in exactly the same pattern as Sereal. Presumably for the same underlying reasons. (Will report as a bug in Data::Dumper.) This is why the Dumper statements above look at specific array elements. -zefram


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.