develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #60294] threads::shared resets %hash iterators

Thread Next
From:
James E Keenan via RT
Date:
May 26, 2013 17:14
Subject:
[perl #60294] threads::shared resets %hash iterators
Message ID:
rt-3.6.HEAD-2650-1369588467-1220.60294-15-0@perl.org
On Sat Nov 01 11:30:29 2008, kbrintn@netstats-poll-07.ip.qwest.net wrote:
> 
> This is a bug report for perl from kbrintn@netstats-poll-
>    07.ip.qwest.net,
> generated with the help of perlbug 1.35 running under perl v5.8.8.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> I am passing a hash-of-hashes from one thread toa nother.
> 
> I found that if I iterate over the inner hashes with each
> %{$outer{inner}}, it loops forever on the first key. It looks like
>    every
> use of $outer{inner} is resetting the hash iterator for the inner
>    hash.
> 
> This program illustrates the problem:
> 
> #################################################################
> 
> #!/usr/bin/perl
> 
> use strict;
> use threads;
> use threads::shared;
> 
> my %outer :shared;
> 
> $outer{inner} = &share({});
> %{$outer{inner}} = map { $_ => $_ } 'a'..'z';
> 
> ###################################
> 
> print "threads version: $threads::VERSION\n";
> print "threads::shared version: $threads::shared::VERSION\n";
> 
> print "By taking a reference first...\n";
> 
> my $iter = 0;
> {
>     my $ref = $outer{inner};
>     while ($iter++ < 10)
>     {
>         last unless (my ($k, $v) = each %$ref);
>         print "$k ";
>     }
> }
> 
> print " ...and so on\n\n";
> 
> ###################################
> 
> print "By de-ref the shared hash-of-hashes each time...\n";
> 
> $iter = 0;
> while ($iter++ < 10)
> {
>     last unless (my ($k, $v) = each %{$outer{inner}});
>     print "$k ";
> }
> 
> print " ...and so on\n";
> 
> #################################################################
> 
> On my system it outputs as follows:
> 
> threads version: 1.07
> threads::shared version: 0.94
> By taking a reference first...
> w r a x d j y u k h  ...and so on
> 
> By de-ref the shared hash-of-hashes each time...
> w w w w w w w w w w  ...and so on
> 


Is there anyone who has built a threaded perl on 5.18 who could check
out the issues raised in this older ticket?

Thank you very much.
Jim Keenan


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=60294

Thread Next


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