Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB::sub is not called for 'eval' #15617

Open
p5pRT opened this issue Sep 20, 2016 · 5 comments
Open

DB::sub is not called for 'eval' #15617

p5pRT opened this issue Sep 20, 2016 · 5 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Sep 20, 2016

Migrated from rt.perl.org#129315 (status was 'open')

Searchable as RT129315$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 20, 2016

From @KES777

Created by @KES777

$cat t.pl
sub t0 { };

t0();
eval { 1; };
eval " 1; ";

$cat Devel/DB.pm
package DB;

sub DB {
  print "Stack trace\n";
  $l = 0;
  print " @​l[1,2,3]\n" while @​l = caller($l++);
}

sub sub {
  print "$DB​::sub is called\n";

  goto &$DB​::sub;
}

1;

$perl -I. -d​:DB t.pl
Stack trace
  t.pl 3 DB​::DB
main​::t0 is called
Stack trace
  t.pl 1 DB​::DB
  t.pl 3 main​::t0 #<<<< We see the main​::t0 frame
Stack trace
  t.pl 4 DB​::DB
Stack trace
  t.pl 4 DB​::DB
  t.pl 4 (eval) #<<<< We see the (eval) frame
Stack trace
  t.pl 5 DB​::DB
Stack trace
  (eval 1)[t.pl​:5] 1 DB​::DB
  t.pl 5 (eval) #<<<< We see the (eval) frame

Despite on the (eval) frames are created the DB​::sub is not called for them.

Expected behaviour​:
DB​::sub should be called for 'eval'

Perl Info

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

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 20, 2016

From @cpansprout

On Tue Sep 20 07​:55​:50 2016, kes-kes@​yandex.ru wrote​:

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]
$cat t.pl
sub t0 { };

t0();
eval { 1; };
eval " 1; ";

$cat Devel/DB.pm
package DB;

sub DB {
print "Stack trace\n";
$l = 0;
print " @​l[1,2,3]\n" while @​l = caller($l++);
}

sub sub {
print "$DB​::sub is called\n";

goto &$DB​::sub;
}

What value would you put in $DB​::sub in that case? There is no valid value for which ‘goto &$DB​::sub’ will work and call the eval. Evals do not work that way.

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 20, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 20, 2016

From @KES777

Maybe we require to supply different hooks so debugger will know that 'eval' is in effect now.
Checking for the (caller)[3] eq '(eval)' all the time is too resource wasting.

Lack of that feature prevents us to make step over eval/require/use while debugging​:

$ cat t3.pl
eval {
  1+1;
  2+2;
};

$ perl -Ilib -I/home/kes/tmp -d ~/tmp/t3.pl

Loading DB routines from perl5db.pl version 1.49_04
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main​::(/home/kes/tmp/t3.pl​:1)​: eval {
  DB<1> n
main​::(/home/kes/tmp/t3.pl​:2)​: 1+1;
  DB<1> n
main​::(/home/kes/tmp/t3.pl​:3)​: 2+2;

As you can see we fall into eval instead of step over as expected.

20.09.2016, 19​:52, "Father Chrysostomos via RT" <perlbug-followup@​perl.org>​:

On Tue Sep 20 07​:55​:50 2016, kes-kes@​yandex.ru wrote​:

 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]
 $cat t.pl
 sub t0 { };

 t0();
 eval { 1; };
 eval " 1; ";

 $cat Devel/DB.pm
 package DB;

 sub DB {
     print "Stack trace\n";
     $l = 0;
     print " @​l[1,2,3]\n" while @​l = caller($l++);
 }

 sub sub {
     print "$DB​::sub is called\n";

 goto &$DB​::sub;
 }

What value would you put in $DB​::sub in that case? There is no valid value for which ‘goto &$DB​::sub’ will work and call the eval. Evals do not work that way.

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 20, 2016

From @KES777

What value would you put in $DB​::sub in that case? There is no valid value for which ‘goto &$DB​::sub’ will work and call the eval. Evals do not work that way.

sub CORE​::eval {
  &make_real_call_to_eval;
}

and then when we call under `-d` flag

  eval '1+2;'

The DB​::sub will be called and the \&CORE​::eval assigned to $DB​::sub. So 'goto &$DB​::sub' will call CORE​::eval which in its turn will &make_real_call_to_eval
In this case we will see true PP subroutine frame from caller too instead of the hack '(eval)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant