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

Storable cannot handle threads::shared tied hashes and arrays #8320

Open
p5pRT opened this issue Feb 6, 2006 · 9 comments
Open

Storable cannot handle threads::shared tied hashes and arrays #8320

p5pRT opened this issue Feb 6, 2006 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 6, 2006

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

Searchable as RT38443$

@p5pRT
Copy link
Author

p5pRT commented Feb 6, 2006

From laocoon@fastmail.fm

Created by laocoon@fastmail.fm

This is a bug report for perl from laocoon@​fastmail.fm,
generated with the help of perlbug 1.35 running under perl v5.8.7.

-----------------------------------------------------------------

Storable seems to have problems thawing shared hashes and arrays correctly.

% perl -Mthreads -Mthreads​::shared -wle 'use Storable qw/freeze thaw/;
my %foo : shared; $foo{bar} = 1; print thaw( freeze( \%foo ) )->{bar};'
Can't locate object method "FETCH" via package "threads​::shared​::tie" at
-e line 1.
% perl -Mthreads -Mthreads​::shared -wle 'use Storable qw/freeze thaw/;
my @​foo : shared; $foo[0] = 1; print thaw( freeze( \@​foo ) )->[0];'
Can't locate object method "FETCH" via package "threads​::shared​::tie" at
-e line 1.

Confirmed with 5.8.7, Storable v2.13, threads v1.05, threads​::shared v0.93
and 5.9.3, Storable v2.15_02, threads v1.07, threads​::shared v0.94.

Perl Info

Flags:
    category=library
    severity=medium

Site configuration information for perl v5.8.7:

Configured by frey at Thu Nov 10 09:35:33 CET 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=freebsd, osvers=6.0-stable, 
archname=i386-freebsd-thread-multi-64int
    uname='freebsd . 6.0-stable freebsd 6.0-stable #0: wed nov 9 
13:59:41 cet 2005 frey@.:usrobjusrsrcsysgeneric_with_ipfw i386 '
    config_args='-sde -Dprefix=/usr/local 
-Darchlib=/usr/local/lib/perl5/5.8.7/mach 
-Dprivlib=/usr/local/lib/perl5/5.8.7 
-Dman3dir=/usr/local/lib/perl5/5.8.7/perl/man/man3 
-Dman1dir=/usr/local/man/man1 
-Dsitearch=/usr/local/lib/perl5/site_perl/5.8.7/mach 
-Dsitelib=/usr/local/lib/perl5/site_perl/5.8.7 
-Dscriptdir=/usr/local/bin 
-Dsiteman3dir=/usr/local/lib/perl5/5.8.7/man/man3 
-Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv 
-Uinstallusrbinperl -Dcc=cc -Duseshrplib 
-Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.7/BSDPAN" 
-Doptimize=-O2 -fno-strict-aliasing -pipe  -Ud_dosuid -Ui_gdbm 
-Dusethreads -Dusemymalloc=n -Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define 
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.7/BSDPAN" 
-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe 
-I/usr/local/include',
    optimize='-O2 -fno-strict-aliasing -pipe ',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.7/BSDPAN" 
-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe 
-I/usr/local/include'
    ccversion='', gccversion='3.4.4 [FreeBSD] 20050518', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, 
Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-pthread -Wl,-E -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil
    perllibs=-lm -lcrypt -lutil
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  
-Wl,-R/usr/local/lib/perl5/5.8.7/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    defined-or


@INC for perl v5.8.7:
    /usr/local/lib/perl5/site_perl/5.8.7/mach
    /usr/local/lib/perl5/site_perl/5.8.7
    /usr/local/lib/perl5/site_perl
    /usr/local/lib/perl5/5.8.7/BSDPAN
    /usr/local/lib/perl5/5.8.7/mach
    /usr/local/lib/perl5/5.8.7
    .


Environment for perl v5.8.7:
    HOME=/home/frey
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=/usr/local/libexec/ccache/:/usr/local/libexec/ccache/:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/frey/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/zsh


@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2010

From au@hcsd.de

Hi all!

On Mo. 06. Feb. 2006, 07​:46​:15, lao wrote​:

Storable seems to have problems thawing shared hashes and arrays
correctly.

The problem is still present in recent Perl versions (verified against
self-compiled Perl 5.8.9 on Linux+Solaris and Debian provided Perl
5.10). This is was my test code​:

  #!/usr/bin/perl

  use strict;
  use warnings;
  use utf8;

  use threads;
  use threads​::shared;

  use Data​::Dumper;
  use Storable;

  my $data = {
  'a' => {
  'b' => undef,
  }
  };

  my $x = shared_clone( $data );

  print Dumper([ $x ]);

  my $y = Storable​::freeze( $x );
  my $z = Storable​::thaw( $y );

  print Dumper([ $z ]);

Error message is​:

  Can't locate object method "FETCH" via package "threads​::shared​::tie"
at /usr/lib/perl/5.10/Data/Dumper.pm line 190

What needs to be done to make module Storable work on tied hashes and
arrays?

Best regards,

Stephan

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2010

From au@hcsd.de

t.pl

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2010

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

@p5pRT
Copy link
Author

p5pRT commented Apr 15, 2010

From au@hcsd.de

This bug is still present in Perl 5.12.0 – serializing shared Hashes and
Arrays does not work

@p5pRT
Copy link
Author

p5pRT commented Apr 15, 2010

From [Unknown Contact. See original ticket]

This bug is still present in Perl 5.12.0 – serializing shared Hashes and
Arrays does not work

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 2012

From mokalan@gmail.com

Still present in 5.16.1

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 2012

From [Unknown Contact. See original ticket]

Still present in 5.16.1

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2017

From @tonycoz

On Fri, 09 Apr 2010 11​:21​:48 -0700, stephan_a wrote​:

Hi all!

On Mo. 06. Feb. 2006, 07​:46​:15, lao wrote​:

Storable seems to have problems thawing shared hashes and arrays
correctly.

The problem is still present in recent Perl versions (verified against
self-compiled Perl 5.8.9 on Linux+Solaris and Debian provided Perl
5.10). This is was my test code​:

\#\!/usr/bin/perl

use strict;
use warnings;
use utf8;

use threads;
use threads​::shared;

use Data​::Dumper;
use Storable;

my $data = \{
    'a' => \{
        'b' => undef\,
    \}
\};

my $x = shared\_clone\( $data \);

print Dumper\(\[ $x \]\);

my $y = Storable​::freeze\( $x \);
my $z = Storable​::thaw\( $y \);

print Dumper\(\[ $z \]\);

Error message is​:

Can't locate object method "FETCH" via package "threads​::shared​::tie"

at /usr/lib/perl/5.10/Data/Dumper.pm line 190

What needs to be done to make module Storable work on tied hashes and
arrays?

Storable does work on tied hashes and arrays, and preserves the tie through the freeze()/thaw().

While threads​::shared could be modified to provide the normal FETCH etc methods, I can't see it as practical to reattach the SV to its common shared SV.

I guess the change you're looking for is a way to *not* preserve the tie through the freeze/thaw process.

Tony

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