5.10 threads :: shared message

Discussion in 'Perl Misc' started by Abble, Dec 20, 2007.

  1. Abble

    Abble Guest

    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???
     
    Abble, Dec 20, 2007
    #1
    1. Advertisements

  2. Abble <> writes:

    > 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.
     
    Joost Diepenmaat, Dec 20, 2007
    #2
    1. Advertisements

  3. Abble

    Abble Guest

    Re: 5.10 threads :: shared message

    On Dec 20, 10:07 am, Joost Diepenmaat <> wrote:
    > Abble <> writes:
    > > 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.


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


    Thanks!
     
    Abble, Dec 20, 2007
    #3
  4. Abble

    Ben Morrow Guest

    Quoth 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 );


    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
     
    Ben Morrow, Dec 20, 2007
    #4
  5. Abble

    Ben Morrow Guest

    Quoth Ben Morrow <>:
    > Quoth Abble <>:
    > > I get:
    > >
    > > "Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."
    > >
    > > when I do:

    <snip>
    >
    > 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
     
    Ben Morrow, Dec 20, 2007
    #5
  6. Abble

    zentara Guest

    On Thu, 20 Dec 2007 08:00:44 -0800 (PST), Abble <>
    wrote:

    >
    > 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

    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html
     
    zentara, Dec 22, 2007
    #6
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev
    Replies:
    3
    Views:
    16,423
    Gandalf
    Feb 8, 2004
  2. Joe Fallon
    Replies:
    3
    Views:
    858
    =?Utf-8?B?Z3V5?=
    Jul 16, 2004
  3. ben
    Replies:
    3
    Views:
    592
    Kevin Spencer
    Nov 15, 2004
  4. tshad
    Replies:
    11
    Views:
    927
    tshad
    May 27, 2005
  5. Imran Aziz
    Replies:
    1
    Views:
    606
    Stefan
    Aug 22, 2005
Loading...

Share This Page