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

[perl #129202] The 'sub DB' pad stack isn't getting pushed toallocate a new pad

From:
KES
Date:
September 6, 2016 06:09
Subject:
[perl #129202] The 'sub DB' pad stack isn't getting pushed toallocate a new pad
Message ID:
rt-4.0.24-32452-1473080159-1387.129202-75-0@perl.org
# New Ticket Created by  KES 
# Please include the string:  [perl #129202]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=129202 >


To: perlbug@perl.org
Subject: the 'sub DB' pad stack isn't getting pushed to allocate a new pad
Cc: kes-kes@yandex.ru
Message-Id: <5.24.0_23208_1473079814@keswork>
Reply-To: kes-kes@yandex.ru
From: kes-kes@yandex.ru


This is a bug report for perl from kes-kes@yandex.ru,
generated with the help of perlbug 1.40 running under perl 5.24.0.


-----------------------------------------------------------------
[Please describe your issue here]

Here is minified example which shows that memory for '$x' variable is not
allocated again for DB::DB reentrance.

$ cat t3.pl
#!/usr/bin/env perl

sub t0 {}

1;



$ cat Devel/DB.pm
package DB;

use strict;
use warnings;

our $level =  0;

sub DB {
        my $x =  0;
        $x += $level;
        print ">LEVEL: $level; VALUE: $x", \$x,"\n";
        local $level =  $level +1;
        $^D |=  (1<<30)   if $level < 3;
        main::t0();
        print "<LEVEL: $level; VALUE: $x", \$x,"\n";
        return;
}

1;


$ perl -I. -d:DB t3.pl
> LEVEL: 0; VALUE: 0SCALAR(0x1ceb008)
> LEVEL: 1; VALUE: 1SCALAR(0x1ceb008)
> LEVEL: 2; VALUE: 2SCALAR(0x1ceb008)

<LEVEL: 3; VALUE: 2SCALAR(0x1ceb008)
Use of uninitialized value $x in concatenation (.) or string at Devel/DB.pm line 15.
<LEVEL: 2; VALUE: SCALAR(0x1ceb008)
Use of uninitialized value $x in concatenation (.) or string at Devel/DB.pm line 15.
<LEVEL: 1; VALUE: SCALAR(0x1ceb008)

Here we see that for each reentrance the address of $x refer the same place.

Expected output:
> LEVEL: 0; VALUE: 0SCALAR(0xd05008)
> LEVEL: 1; VALUE: 1SCALAR(0xcfb6c8)
> LEVEL: 2; VALUE: 2SCALAR(0xd29ea8)

<LEVEL: 3; VALUE: 2SCALAR(0xd29ea8)
<LEVEL: 2; VALUE: 1SCALAR(0xcfb6c8)
<LEVEL: 1; VALUE: 0SCALAR(0xd05008)


As workaround I may do:
sub workaround {
    my $x =  0;
    $x += $level;
    print ">LEVEL: $level; VALUE: $x", \$x,"\n";
    local $level =  $level +1;
    $^D |=  (1<<30)   if $level < 3;
    main::t0();
    print "<LEVEL: $level; VALUE: $x", \$x,"\n";
    return;
}
sub DB {
    workaround();
}

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

Configured by kes at Sun Jun  5 14:58:33 EEST 2016.

Summary of my perl5 (revision 5 version 24 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=3.13.0-37-generic, archname=x86_64-linux
    uname='linux keswork 3.13.0-37-generic #64-ubuntu smp mon sep 22 21:28:38 utc 2014 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/kes/perl5/perlbrew/perls/perl-5.24.0 -Aeval:scriptdir=/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.4', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.19'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    Devel::PatchPerl 1.38

---
@INC for perl 5.24.0:
    /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/x86_64-linux
    /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0
    /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/x86_64-linux
    /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0
    .

---
Environment for perl 5.24.0:
    HOME=/home/kes
    LANG=ru_UA.UTF-8
    LANGUAGE=en
    LC_MESSAGES=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin:/home/kes/perl5/bin:/home/kes/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    PERLBREW=command perlbrew
    PERLBREW_BASHRC_VERSION=0.75
    PERLBREW_HOME=/home/kes/.perlbrew
    PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.24.0/man
    PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin
    PERLBREW_PERL=perl-5.24.0
    PERLBREW_ROOT=/home/kes/perl5/perlbrew
    PERLBREW_VERSION=0.75
    PERL_BADLANG (unset)
    SHELL=/bin/bash




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About