develooper Front page | perl.perl5.porters | Postings from June 2010

[perl #75598] Reversing a default $_ lexicalized in an upper block fails

perl @ profvince . com
June 8, 2010 04:53
[perl #75598] Reversing a default $_ lexicalized in an upper block fails
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #75598]
# 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.10.1.

[Please describe your issue here]

With the latest blead :

    $ ./perl -Ilib -E '{ my $_ = "foo"; sub z { scalar reverse } } say z'
    Bizarre copy of ARRAY in reverse at -e line 1.

It used to segfault :

    $ perl5.12.1-64 -M5.010 -E '{ my $_ = "foo"; sub z { scalar reverse } } say z'
    Segmentation fault.

At that time, the relevant issue was the one addressed in RT #75436. The crash is fixed, but there's still an underlying problem with change 789bd863840ef4ff6c46f7c2ee0f3f64e0b5daa6.

For some reason Perl_pad_findlex() (thus find_rundefsv() as well) returns an AV instead of $_ in this case :

$ gdb --args ./perl -Ilib -M5.010 -E '{ my $_ = "foo"; sub z { scalar reverse } } say z'
GNU gdb (Gentoo 7.1 p1) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /tmp/git/perl...done.
(gdb) break Perl_croak
Breakpoint 1 at 0x524cf3: file util.c, line 1609.
(gdb) r
Starting program: /tmp/git/perl -Ilib -M5.010 -E \{\ my\ \$_\ =\ \"foo\"\;\ sub\ z\ \{\ scalar\ reverse\ \}\ \}\ say\ z
warning: no loadable sections found in added symbol-file /usr/lib64/debug/lib64/
[Thread debugging using libthread_db enabled]

Breakpoint 1, Perl_croak (my_perl=0xa08010, 
    pat=0x7961dd "Bizarre copy of %s in %s") at util.c:1609
1609        va_start(args, pat);
(gdb) bt
#0  Perl_croak (my_perl=0xa08010, pat=0x7961dd "Bizarre copy of %s in %s")
    at util.c:1609
#1  0x00000000005a1879 in Perl_sv_setsv_flags (my_perl=0xa08010, 
    dstr=0xa38060, sstr=0xa379d0, flags=1538) at sv.c:3918
#2  0x000000000061f613 in Perl_pp_reverse (my_perl=0xa08010) at pp.c:5497
#3  0x000000000051cd48 in Perl_runops_debug (my_perl=0xa08010) at dump.c:2096
#4  0x00000000004557fa in S_run_body (my_perl=0xa08010, oldscope=1)
    at perl.c:2309
#5  0x0000000000454a0a in perl_run (my_perl=0xa08010) at perl.c:2233
#6  0x0000000000423aed in main (argc=5, argv=0x7fffffffdf08, 
    env=0x7fffffffdf38) at perlmain.c:117
(gdb) up 2
#2  0x000000000061f613 in Perl_pp_reverse (my_perl=0xa08010) at pp.c:5497
5497                sv_setsv(TARG, SP > MARK ? *SP : find_rundefsv());
(gdb) do
#1  0x00000000005a1879 in Perl_sv_setsv_flags (my_perl=0xa08010, 
    dstr=0xa38060, sstr=0xa379d0, flags=1538) at sv.c:3918
3918                Perl_croak(aTHX_ "Bizarre copy of %s in %s", type, OP_DESC(PL_op));
(gdb) p sstr
$1 = (SV *) 0xa379d0
(gdb) call Perl_sv_dump(my_perl, sstr)
SV = PVAV(0xa0cff8) at 0xa379d0
  REFCNT = 2
  FLAGS = ()
  ARRAY = 0x0
  FILL = -1
  MAX = -1
  ARYLEN = 0x0

[Please do not change anything below this line]
Site configuration information for perl 5.10.1:

Configured by Gentoo at Sat Feb 13 19:44:25 CET 2010.

Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
    osname=linux,, archname=x86_64-linux
    uname='linux fuuka #1 smp sat jan 30 18:37:12 cet 2010 x86_64 intel(r) core(tm)2 duo cpu e6750 @ 2.66ghz genuineintel gnulinux '
    config_args='-des -Duseshrplib -Darchname=x86_64-linux -Dcc=x86_64-pc-linux-gnu-gcc -Doptimize=-march=core2 -O3 -fomit-frame-pointer -ftree-vectorize -ftree-vectorizer-verbose=1 -pipe -DNDEBUG -Dscriptdir=/usr/bin -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr -Dprivlib=/usr/lib64/perl5/5.10.1 -Darchlib=/usr/lib64/perl5/5.10.1/x86_64-linux -Dvendorlib=/usr/lib64/perl5/vendor_perl/5.10.1 -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.10.1/x86_64-linux -Dsitelib=/usr/lib64/perl5/site_perl/5.10.1 -Dsitearch=/usr/lib64/perl5/site_perl/5.10.1/x86_64-linux -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dinstallman1dir=/usr/share/man/man1 -Dinstallman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dlocincpth=  -Duselargefiles -Dd_semctl_semun -Dinc_version_list=5.10.0 5.10.0/x86_64-linux -Dcf_by=Gentoo -Dmyhostname=localhost -Dperladmin=root@localhost -Dinstallusrbinperl=n -Ud_csh -Uusenm -Di_ndbm -Di_gdbm -Di_db -Dusrinc=/usr/incl
 ude -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='x86_64-pc-linux-gnu-gcc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-march=core2 -O3 -fomit-frame-pointer -ftree-vectorize -ftree-vectorizer-verbose=1 -pipe -DNDEBUG',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.4.3', 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='x86_64-pc-linux-gnu-gcc', ldflags =' -fstack-protector'
    libpth=/usr/local/lib64 /lib64 /usr/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -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 -march=core2 -O3 -fomit-frame-pointer -ftree-vectorize -ftree-vectorizer-verbose=1 -pipe -DNDEBUG -fstack-protector'

Locally applied patches:

@INC for perl 5.10.1:

Environment for perl 5.10.1:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About