5.10 threads :: shared message

A

Abble

I get:

"Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."


when I do:

use strict; use English; use warnings;
use Time::HiRes;
use threads;
use threads :: shared;
use Net::ping;


my( %Times, %Samples, %Time, %Avg ) : shared = 1; ## line 10


my( @Vols, $Begins );


Any ideas???
 
J

Joost Diepenmaat

Abble said:
I get:

"Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."

Why are you assigning 1 to a list of hashes?

my( %Times, %Samples, %Time, %Avg ) : shared;

Doesn't give the error. I haven't checked if you can actually assign
attributes this way, though.

Joost.
 
A

Abble

Why are you assigning 1 to a list of hashes?

my( %Times, %Samples, %Time, %Avg ) : shared;

Doesn't give the error. I haven't checked if you can actually assign
attributes this way, though.

Joost.

Oh, the example I saw had the shared = 1 bizness; Will try it
without.


Thanks!
 
B

Ben Morrow

Quoth Abble said:
I get:

"Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."

when I do:

use strict; use English; use warnings;
use Time::HiRes;
use threads;
use threads :: shared;
use Net::ping;


my( %Times, %Samples, %Time, %Avg ) : shared = 1; ## line 10


my( @Vols, $Begins );

Bug in threads::shared. A simpler example is

use threads;
use threads::shared;

my ($x, @y) :shared = (1);

This also existed in 5.8.8, it isn't new in 5.10. The threads::shared
implementation of shared arrays and shared hashes is an evil stinking
mess, made necessary by the fact that perl's magic system isn't really
OO, it just kinda looks that way if you don't look too closely :).

Ben
 
B

Ben Morrow

Bug in threads::shared. A simpler example is

use threads;
use threads::shared;

my ($x, @y) :shared = (1);

Having looked into this further: the bug isn't in threads::shared, it's
in the attribute-handling code. Although this

use Attribute::Handlers;

sub Foo : ATTR {
warn "Applying :$_[3]";
}

my ($x, @y) :Foo = (1);

doesn't give an error with 5.8.8, it does with 5.10.0; and in both cases
it fails to set $x. I've reported this to p5p...

Ben
 
Z

zentara

my( %Times, %Samples, %Time, %Avg ) : shared = 1; ## line 10
Any ideas???

Besides the other advice given, when you share hashes, only the top
level keys get shared. So don't expect a deep hash to be completely
shared unless you explicitly share the deeper keys.

zentara
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top