develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #107766] Erroneous Array Content

Thread Previous | Thread Next
Peter Pietsch
January 8, 2012 18:15
[perl #107766] Erroneous Array Content
Message ID:
# New Ticket Created by  Peter Pietsch 
# Please include the string:  [perl #107766]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.39 running under perl 5.14.2.

I've encountered some kind of memory management glitch. It's 
reproducible and it
exists in all of the versions I've tried:
   5.14.2  x86_64 archlinux
   5.10    debian (guest in virtualbox)
   5.8.8   i386 CentOS (ssh on my hosting provider)
   5.10    i686 Cygwin on XP

In the directory are 2 slightly different 
of my sudoku reduction script (along with some test data), v1 works ok, 
doesn't when the number of output puzzles is greater than 1.

When input-a (the name of a puzzle which has 26 clues) is entered as the 
argument, v1 produces 3 new puzzles, each with 25 clues:


V2-bad also creates 3 new "puzzles" and claims that they have 25 clues:


However, they have only 24 clues. "9" is missing from column 58 in the 
1st and
2nd, and "5" is missing from column 35 in the 3rd. The results for 
inputs B and
C exhibit the same problem. For inputs V and W, only one output puzzle is
generated, and v2-bad works correctly.

It seems to me that in main (at the bottom) of v2-bad, when the code 
block which
constitutes lines 1036 to 1091 - the "while ($newTally)" loop - 
completes its
last iteration and control passes to the following line, at that point, 
all of
the elements in @currentList are magically transformed into keys stolen (or
illegally copied) from hash %newList.

The diff report shows 3 modified lines and 2 new lines:

<     for $puzzle (@currentList) {
 >     for $whatever (@currentList) {
 >         $puzzle = $whatever;
<             if ($status = $newList{$minusKloo}) {
 >             $whatever = $minusKloo;
 >             if ($status = $newList{$whatever}) {
<                 $newList{$minusKloo} = $status
 >                 $newList{$whatever} = $status

The 2 additional lines in v2-bad:
1056    $puzzle = $whatever;
1069        $whatever = $minusKloo;

--> are in effect, dummies or stand ins for the 2 lines below from the real
         $puzzle = unzip_key($zip_key);
             $zip_key = compress_key($minusKloo);

In the real (meaning my preferred) version, I'm using a shorter, encrypted
format for the elements and keys in @currentList and %newList, instead 
of the
longer format found in v1 and v2. The format has no effect on the problem.

The code differences between v1 and v2 shouldn't have any effect on the
functionality, so I think it's a Perl bug. I've employed a work around in to get past the problem.

Thanks, and regards,

Site configuration information for perl 5.14.2:

Configured by nobody at Thu Dec 29 20:28:11 UTC 2011.

Summary of my perl5 (revision 5 version 14 subversion 2) configuration:

     osname=linux, osvers=3.1.6-1-arch, archname=x86_64-linux-thread-multi
     uname='linux marin 3.1.6-1-arch #1 smp preempt thu dec 22 09:11:48 
cet 2011 x86_64 intel(r) core(tm) i7 cpu 920 @ 2.67ghz genuineintel 
gnulinux '
     config_args='-des -Dusethreads -Duseshrplib 
-Doptimize=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector 
--param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Dprefix=/usr 
-Dinstallprefix=/usr -Dvendorprefix=/usr 
-Dprivlib=/usr/share/perl5/core_perl -Darchlib=/usr/lib/perl5/core_perl 
-Dsitelib=/usr/share/perl5/site_perl -Dsitearch=/usr/lib/perl5/site_perl 
-Dvendorarch=/usr/lib/perl5/vendor_perl -Dscriptdir=/usr/bin/core_perl 
-Dsitescript=/usr/bin/site_perl -Dvendorscript=/usr/bin/vendor_perl 
-Dinc_version_list=none -Dman1ext=1perl -Dman3ext=3perl 
-Dcccdlflags='-fPIC' -Dlddlflags=-shared 
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=define, usemultiplicity=define
     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
     use64bitint=define, use64bitall=define, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
     cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing 
-pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE 
     optimize='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector 
--param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2',
     cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe 
-fstack-protector -I/usr/local/include'
     ccversion='', gccversion='4.6.2 20111125 (prerelease)', gccosandvers=''
     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags 
-fstack-protector -L/usr/local/lib'
     libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
     libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc 
     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
     libc=/lib/, so=so, useshrplib=true,
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E 
     cccdlflags='-fPIC', lddlflags='-shared 
-L/usr/local/lib -fstack-protector'

Locally applied patches:

@INC for perl 5.14.2:

Environment for perl 5.14.2:
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PERL_BADLANG (unset)

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About