develooper Front page | perl.perl5.porters | Postings from December 2017

[perl #38443] Storable cannot handle threads::shared tied hashes andarrays

From:
Tony Cook via RT
Date:
December 11, 2017 00:47
Subject:
[perl #38443] Storable cannot handle threads::shared tied hashes andarrays
Message ID:
rt-4.0.24-22083-1512953229-1218.38443-15-0@perl.org
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

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=38443



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About