You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm trying to use Clone::clone to copy a hash which is shared among threads,
but when the result is accessed, Perl dies with
"Can't locate object method "FETCH" via package "threads::shared::tie"
at ..."
Here's an example:
#!/usr/bin/perluse strict; use warnings;
use threads;
use threads::shared;
use Clone;
my$a = shared_clone { foo=> 100, bar=> 200 };
my$b = Clone::clone($a);
print$b->{foo}, "\n"; #crashes here
On 05/15/2014 03:16 PM, Breno G. de Oliveira via RT wrote:
| I don't think Clone is thread-safe.
| Are you able to reproduce the issue if you use Storable's dclone()
instead of Clone's clone()?
I'm not familiar with Storable, but gave it a try. The result of
dclone() can not be
de-referenced either, but the error is different:
#!/usr/bin/perluse strict; use warnings; use threads; use threads::shared;
use Storable qw(dclone);
my$a = shared_clone { foo=> 100, bar=> 200 };
my$b = dclone($a);
# The next statement crashes with:
# Can't locate object method "FETCH" via package "threads::shared::tie"
print $b->{foo}, "\n";
Unfortunately threads::shared implements the sharing with tie-s to threads::shared::tie, but it makes zero sense to have a clone take part in the sharing -- if you wanted that, you would use the original variable, not the clone... Clone and Storable will (dirtily) have to special case that an remove all tie-s to threads::shared::tie, to be able to cooperate with threads::shared. Note that threads::shared itself has the same problem, you can't send a structure over a Thread::Queue and return the sent object over this or another Threads::Queue, this will crash after one or more iterations (I don't remember).
Ralf
Migrated from rt.cpan.org#93821 (status was 'open')
Requestors:
From [email protected] on 2014-03-13 05:13:10:
-Jim
From [email protected] on 2014-05-15 22:16:59:
From [email protected] on 2014-05-15 23:31:38:
From [email protected] on 2015-11-06 16:20:09:
From [email protected] on 2015-11-06 16:32:17:
The text was updated successfully, but these errors were encountered: