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

[perl #119797] lvalue sub shows "Bizarre copy of ARRAY in block exit" in very specific case.

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
September 15, 2013 13:21
Subject:
[perl #119797] lvalue sub shows "Bizarre copy of ARRAY in block exit" in very specific case.
Message ID:
rt-3.6.HEAD-1873-1379251260-963.119797-15-0@perl.org
On Sun Sep 15 03:08:16 2013, glitchmr@myopera.com wrote:
> 
> This is a bug report for perl from glitchmr@myopera.com,
> generated with the help of perlbug 1.39 running under perl 5.18.1.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> Following code involving lvalue shows "Bizarre copy of ARRAY in block
> exit". I've experimented with it, and it seems to happen with any
> array (lexical or global), as long the `if` condition involves array
> somehow, and returns false (for example, `if (@array, 0)`), and `else`
> block returns `@array` without `return` keyword.
> 
>     # The subroutine has to be declared as lvalue, so you can write to
>     # it in order to trigger the bug.
>     sub array : lvalue {
>         # This test has to involve @array somehow, but fail.
>         if (@array) {
>             # The contents of if block don't matter, so I left this
>             # block empty. It just has to exist.
>         }
>         else {
>             # The else condition has to return @array. Return keyword
>             # cannot be used for this bug to trigger.
>             @array;
>         }
>     }
>     # Now, to trigger the bug, it's enough to write to array.
>     (array) = ();
> 


1. I cannot reproduce the error you cite.  I cannot generate this error:
 ""Bizarre copy of ARRAY in block exit".

2. Did you try running your program with 'use strict; use warnings;'? 
If so, you would have gotten messages that indicated problematic code.

3. Did you try rewriting your program to name the subroutine something
other than 'array'?  That only made for a more confusing bug report.

Once I started to debug this with steps 2 and 3 above, I found that I
could get an executable (though not very useful) program  by simply
placing '()' after the subroutine call.

##########
$ cat 119797-lvalue.pl 
my @this = (1..5);

(that()) = ();
print "@this\n";

sub that :lvalue { if (@this) { } else { @this; } }
##########
$ perl 119797-lvalue.pl 
1 2 3 4 5
##########

I don't think there is a bug here.



> [Please do not change anything below this line]
> -----------------------------------------------------------------
> ---
> Flags:
>     category=core
>     severity=medium
> ---
> Site configuration information for perl 5.18.1:
> 
> Configured by nobody at Tue Aug 13 13:22:58 CEST 2013.
> 
> Summary of my perl5 (revision 5 version 18 subversion 1) configuration:
>    
>   Platform:
>     osname=linux, osvers=3.10.5-1-arch,
>     archname=x86_64-linux-thread-multi
>     uname='linux mnt-chroots-arch-extra-x86_64-flo-64 3.10.5-1-arch #1
>     smp preempt mon aug 5 08:04:22 cest 2013 x86_64 gnulinux '
>     config_args='-des -Dusethreads -Duseshrplib -Doptimize=-march=x86-64
>     -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4
>     -Dprefix=/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
>     -Dldflags=-Wl,-O1,--sort-common,--as-needed,-z,relro'
>     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',
>     cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
>     -fstack-protector -I/usr/local/include'
>     ccversion='', gccversion='4.8.1 20130725 (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
>     -fstack-protector -L/usr/local/lib'
>     libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
>     /lib64 /usr/lib64
>     libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
>     -lgdbm_compat
>     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
>     libc=/lib/libc-2.17.so, so=so, useshrplib=true, libperl=libperl.so
>     gnulibc_version='2.17'
>   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 -L/usr/local/lib
>     -fstack-protector'
> 
> Locally applied patches:
>     
> 
> ---
> @INC for perl 5.18.1:
>     /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.18.1:
>     HOME=/home/glitchmr
>     LANG=pl_PL.UTF-8
>     LANGUAGE (unset)
>     LD_LIBRARY_PATH (unset)
>     LOGDIR (unset)
>     PATH=/usr/bin
>     PERL_BADLANG (unset)
>     SHELL=/usr/bin/fish




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

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