Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot restore overloading on HASH with self-ref. structures #12627

Open
p5pRT opened this issue Dec 3, 2012 · 4 comments
Open

Cannot restore overloading on HASH with self-ref. structures #12627

p5pRT opened this issue Dec 3, 2012 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 3, 2012

Migrated from rt.perl.org#115980 (status was 'open')

Searchable as RT115980$

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2012

From jens.schmidt35@arcor.de

Created by jens.schmidt35@arcor.de

Storable​::retrieve fails with the error message​:

  Cannot restore overloading on HASH(0x1409928) (package <unknown>) at /home/jschmidt/lib/perl-latest/lib/5.16.2/x86_64-linux-thread-multi/Storable.pm line 380, at overload-bug.pl line 55.

given that the following preconditions are met​:

- operator overloading is in use
- an object with overloaded operators refers to itself
- STORABLE_freeze, STORABLE_thaw hooks are used

Here is the test case, run as "perl overload-bug.pl"​:

----- snip -----
use strict;
use warnings;
use Storable qw( nstore retrieve );

{
  package Foo;

  use Scalar​::Util qw( refaddr );

  use overload '==' => \&_equal;
  use overload 'fallback' => 0;

  sub _equal
  {
  return refaddr( $_[0] ) == refaddr( $_[1] );
  }

  sub STORABLE_freeze
  {
  my ( $self, $cloning ) = @​_;

  return () if ( $cloning );

  my $nvpa = { %{$self} };
  return ( undef(), $nvpa );

  }

  sub STORABLE_thaw
  {
  my ( $self, $cloning, $serialized, $nvpa ) = @​_;

  return if ( $cloning );

  %{$self} = %{$nvpa};
  }

  sub new
  {
  my $class = shift( @​_ );
  my $self = { @​_ };
  bless( $self, $class );
  return $self;
  }
}

{
  my $foo = new Foo();
  $foo->{'foo'} = $foo;
  nstore( $foo, "test.storable" );
}

{
  my $foo = retrieve( "test.storable" );
}
----- snip -----

Perl Info

Flags:
    category=library
    severity=high
    module=Storable

Site configuration information for perl 5.16.2:

Configured by jschmidt at Mon Dec  3 14:04:03 CET 2012.

Summary of my perl5 (revision 5 version 16 subversion 2) configuration:
   
  Platform:
    osname=linux, osvers=2.6.39-200.32.1.el6uek.x86_64, archname=x86_64-linux-thread-multi
    uname='linux lu0053 2.6.39-200.32.1.el6uek.x86_64 #1 smp wed sep 26 23:11:38 pdt 2012 x86_64 x86_64 x86_64 gnulinux '
    config_args='-d -Dusethreads=yes -Dusevendorprefix=no -Dprefix=/home/jschmidt/lib/perl-latest'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.4.6 20120305 (Red Hat 4.4.6-4)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.12'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    


@INC for perl 5.16.2:
    /home/jschmidt/lib/perl-latest/lib/site_perl/5.16.2/x86_64-linux-thread-multi
    /home/jschmidt/lib/perl-latest/lib/site_perl/5.16.2
    /home/jschmidt/lib/perl-latest/lib/5.16.2/x86_64-linux-thread-multi
    /home/jschmidt/lib/perl-latest/lib/5.16.2
    .


Environment for perl 5.16.2:
    HOME=/home/jschmidt
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/jschmidt/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Feb 17, 2017

From @jkeenan

On Mon, 03 Dec 2012 15​:28​:30 GMT, jeschmid wrote​:

This is a bug report for perl from jens.schmidt35@​arcor.de,
generated with the help of perlbug 1.39 running under perl 5.16.2.

-----------------------------------------------------------------
[Please describe your issue here]

Storable​::retrieve fails with the error message​:

Cannot restore overloading on HASH(0x1409928) (package <unknown>) at
/home/jschmidt/lib/perl-latest/lib/5.16.2/x86_64-linux-thread-
multi/Storable.pm line 380, at overload-bug.pl line 55.

given that the following preconditions are met​:

- operator overloading is in use
- an object with overloaded operators refers to itself
- STORABLE_freeze, STORABLE_thaw hooks are used

Here is the test case, run as "perl overload-bug.pl"​:

----- snip -----
use strict;
use warnings;
use Storable qw( nstore retrieve );

{
package Foo;

use Scalar​::Util qw( refaddr );

use overload '==' => \&_equal;
use overload 'fallback' => 0;

sub _equal
{
return refaddr( $_[0] ) == refaddr( $_[1] );
}

sub STORABLE_freeze
{
my ( $self, $cloning ) = @​_;

return () if ( $cloning );

my $nvpa = { %{$self} };
return ( undef(), $nvpa );

}

sub STORABLE_thaw
{
my ( $self, $cloning, $serialized, $nvpa ) = @​_;

return if ( $cloning );

%{$self} = %{$nvpa};
}

sub new
{
my $class = shift( @​_ );
my $self = { @​_ };
bless( $self, $class );
return $self;
}
}

{
my $foo = new Foo();
$foo->{'foo'} = $foo;
nstore( $foo, "test.storable" );
}

{
my $foo = retrieve( "test.storable" );
}
----- snip -----

Confirming that this problem still exists in perl-5.24.1, Storable version 2.56_01​:

#####
$ perl 115980-overload-bug.pl
Cannot restore overloading on HASH(0x15e05a0) (package <unknown>) at ... Storable.pm line 389, at 115980-overload-bug.pl line 54.
#####

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags​:
category=library
severity=high
module=Storable
---
Site configuration information for perl 5.16.2​:

Configured by jschmidt at Mon Dec 3 14​:04​:03 CET 2012.

Summary of my perl5 (revision 5 version 16 subversion 2)
configuration​:

Platform​:
osname=linux, osvers=2.6.39-200.32.1.el6uek.x86_64, archname=x86_64-
linux-thread-multi
uname='linux lu0053 2.6.39-200.32.1.el6uek.x86_64 #1 smp wed sep 26
23​:11​:38 pdt 2012 x86_64 x86_64 x86_64 gnulinux '
config_args='-d -Dusethreads=yes -Dusevendorprefix=no
-Dprefix=/home/jschmidt/lib/perl-latest'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.4.6 20120305 (Red Hat 4.4.6-4)',
gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries​:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib
/lib64 /usr/lib64 /usr/local/lib64
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.12'
Dynamic Linking​:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-
protector'

Locally applied patches​:

---
@​INC for perl 5.16.2​:
/home/jschmidt/lib/perl-latest/lib/site_perl/5.16.2/x86_64-linux-
thread-multi
/home/jschmidt/lib/perl-latest/lib/site_perl/5.16.2
/home/jschmidt/lib/perl-latest/lib/5.16.2/x86_64-linux-thread-
multi
/home/jschmidt/lib/perl-latest/lib/5.16.2
.

---
Environment for perl 5.16.2​:
HOME=/home/jschmidt
LANG=C
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/lib64/qt-
3.3/bin​:/bin​:/usr/bin​:/usr/local/sbin​:/usr/sbin​:/sbin​:/home/jschmidt/bin
PERL_BADLANG (unset)
SHELL=/bin/bash

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Feb 17, 2017

From @jkeenan

115980-overload-bug.pl

@p5pRT
Copy link
Author

p5pRT commented Feb 17, 2017

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants