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

[perl #107766] Erroneous Array Content

Thread Previous | Thread Next
From:
Peter Pietsch
Date:
January 8, 2012 18:15
Subject:
[perl #107766] Erroneous Array Content
Message ID:
rt-3.6.HEAD-14510-1326071873-1652.107766-75-0@perl.org
# New Ticket Created by  Peter Pietsch 
# Please include the string:  [perl #107766]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=107766 >


This is a bug report for perl from peter741@dodo.com.au,
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 http://ppietsch.com/my-perl/ are 2 slightly different 
versions
of my sudoku reduction script (along with some test data), v1 works ok, 
v2-bad
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 
input
argument, v1 produces 3 new puzzles, each with 25 clues:

----3---5--78-63-------4--6-----2-59--6---2--54-3-----7--9-------86-71--3---21---
---73---5--78-63-------4--6-----2--9--6---2--54-3-----7--9-------86-71--3---21---
---73---5--78-63-------4--6-----2-59--6---2--54-3-----7----------86-71--3---21---

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

----3---5--78-63-------4--6-----2-59--6---2--54-3-----7----------86-71--3---21---
---73---5--78-63-------4--6-----2--9--6---2--54-3-----7----------86-71--3---21---
---73---5--78-63-------4--6-----2--9--6---2--54-3-----7----------86-71--3---21---

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:

diff sreduce-v1.pl sreduce-v2-bad.pl
1055c1055,1056
<     for $puzzle (@currentList) {
---
 >     for $whatever (@currentList) {
 >         $puzzle = $whatever;
1068c1069,1070
<             if ($status = $newList{$minusKloo}) {
---
 >             $whatever = $minusKloo;
 >             if ($status = $newList{$whatever}) {
1079c1081
<                 $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
version, sreduce.pl:
         $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
sreduce.pl to get past the problem.

Thanks, and regards,
Peter


---
Flags:
     category=core
     severity=high
---
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:

   Platform:
     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 
-Dvendorlib=/usr/share/perl5/vendor_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 
-Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu 
-Dldflags=-Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu'
     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
   Compiler:
     cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing 
-pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64',
     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', 
lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags 
='-Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu 
-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 
-lgdbm_compat
     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
     libc=/lib/libc-2.14.1.so, so=so, useshrplib=true, libperl=libperl.so
     gnulibc_version='2.14.1'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E 
-Wl,-rpath,/usr/lib/perl5/core_perl/CORE'
     cccdlflags='-fPIC', lddlflags='-shared 
-Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu 
-L/usr/local/lib -fstack-protector'

Locally applied patches:


---
@INC for perl 5.14.2:
     /usr/lib/perl5/site_perl
     /usr/share/perl5/site_perl
     /usr/lib/perl5/vendor_perl
     /usr/share/perl5/vendor_perl
     /usr/lib/perl5/core_perl
     /usr/share/perl5/core_perl
     .

---
Environment for perl 5.14.2:
     HOME=/home/peter
     LANG=en_US.UTF-8
     LANGUAGE=
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/peter/bin
     PERL_BADLANG (unset)
     SHELL=/bin/bash

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


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