[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

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



# New Ticket Created by  kbrintn@netstats-poll-07.ip.qwest.net 
# Please include the string:  [perl #60294]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=60294 >



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

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.8.8:

Configured by kbrintn at Fri Oct 31 20:44:57 UTC 2008.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=freebsd, osvers=7.0-release-p4, archname=i386-freebsd-thread-multi-64int
    uname='freebsd netstats-poll-07.ip.qwest.net 7.0-release-p4 freebsd 7.0-release-p4 #0: wed sep 10 23:44:36 utc 2008 kbrintn@netstats-poll-07.ip.qwest.net:usrobjusrsrcsysgeneric i386 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-g -DDEBUGGING -Ud_dosuid -Ui_gdbm -Dusethreads=y -Dusemymalloc=n -Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
    optimize='-g',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
    ccversion='', gccversion='4.2.1 20070719  [FreeBSD]', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-pthread -Wl,-E -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil
    perllibs=-lm -lcrypt -lutil
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    defined-or

---
@INC for perl v5.8.8:
    /usr/local/lib/perl5/5.8.8/BSDPAN
    /usr/local/lib/perl5/site_perl/5.8.8/mach
    /usr/local/lib/perl5/site_perl/5.8.8
    /usr/local/lib/perl5/site_perl/5.8.7
    /usr/local/lib/perl5/site_perl
    /usr/local/lib/perl5/5.8.8/mach
    /usr/local/lib/perl5/5.8.8
    .

---
Environment for perl v5.8.8:
    HOME=/home/kbrintn
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/kbrintn/rrdtool/run/bin:/home/kbrintn/.lib/bin/FreeBSD/7.0-RELEASE-p4/i386:/home/kbrintn/.lib/scripts:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/zsh


[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]