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

wrong line number in error message #12573

Closed
p5pRT opened this issue Nov 17, 2012 · 11 comments
Closed

wrong line number in error message #12573

p5pRT opened this issue Nov 17, 2012 · 11 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Nov 17, 2012

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

Searchable as RT115768$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 17, 2012

From @mauke

Created by @mauke

I think the following is a bug in the core but I'm not sure what's going on​:
#!perl
use strict;
use Carp​::Always;

if (1)
{
  []->();
}
__END__

Output​:
Not a CODE reference at try.pl line 5.

(Expected​: ... line 7.)

I can reproduce this with only core modules​:
#!perl
use strict;
BEGIN { use Carp (); $SIG{__DIE__} = sub { Carp​::croak @​_ } }
#use Carp​::Always;
if (1)
{
  []->();
}
__END__

Output​:
Not a CODE reference at try.pl line 7.
at try.pl line 3.
  main​::__ANON__('Not a CODE reference at try.pl line 7.\x{a}') called at try.pl line 5

Here only the last part "... called at try.pl line 5" is wrong.

I briefly tried to debug this with PERLDB_OPTS='NonStop=1' perl -d try.pl, but
that makes the problem disappear.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.16.2:

Configured by mauke at Thu Nov  1 15:23:47 CET 2012.

Summary of my perl5 (revision 5 version 16 subversion 2) configuration:
   
  Platform:
    osname=linux, osvers=2.6.32-5-686, archname=i686-linux
    uname='linux debian-vb 2.6.32-5-686 #1 smp sun sep 23 09:49:36 utc 2012 i686 gnulinux '
    config_args='-Dprefix=/home/mauke/usr -Doptimize=-O2 -flto -Dldflags=-fstack-protector -L/usr/local/lib -O2 -flto -Dlddlflags=-shared -O2 -flto -L/usr/local/lib -fstack-protector -Dcf_email=l.mai@web.de -Dperladmin=none -de'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -flto',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.7.1', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-fstack-protector -L/usr/local/lib -O2 -flto'
    libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib /usr/lib/i486-linux-gnu /usr/lib64
    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.11.3.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.11.3'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -flto -L/usr/local/lib -fstack-protector'

Locally applied patches:
    SAVEARGV0 - disable magic open in <ARGV>


@INC for perl 5.16.2:
    /home/mauke/usr/lib/perl5/site_perl/5.16.2/i686-linux
    /home/mauke/usr/lib/perl5/site_perl/5.16.2
    /home/mauke/usr/lib/perl5/5.16.2/i686-linux
    /home/mauke/usr/lib/perl5/5.16.2
    /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux
    /home/mauke/usr/lib/perl5/site_perl/5.16.1
    /home/mauke/usr/lib/perl5/site_perl
    .


Environment for perl 5.16.2:
    HOME=/home/mauke
    LANG=en_US.utf8
    LANGUAGE (unset)
    LC_COLLATE=POSIX
    LD_LIBRARY_PATH=/home/mauke/usr/lib
    LOGDIR (unset)
    PATH=/home/mauke/perl5/perlbrew/bin:/home/mauke/.cabal/bin:/home/mauke/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    PERLBREW_BASHRC_VERSION=0.55
    PERLBREW_HOME=/home/mauke/.perlbrew
    PERLBREW_ROOT=/home/mauke/perl5/perlbrew
    PERL_BADLANG (unset)
    PERL_UNICODE=SAL
    SHELL=/bin/bash

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 17, 2012

From @cpansprout

On Fri Nov 16 19​:07​:03 2012, mauke- wrote​:

This is a bug report for perl from l.mai@​web.de,
generated with the help of perlbug 1.39 running under perl 5.16.2.

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

I think the following is a bug in the core but I'm not sure what's
going on​:
#!perl
use strict;
use Carp​::Always;

if (1)
{
[]->();
}
__END__

Output​:
Not a CODE reference at try.pl line 5.

(Expected​: ... line 7.)

I can reproduce this with only core modules​:
#!perl
use strict;
BEGIN { use Carp (); $SIG{__DIE__} = sub { Carp​::croak @​_ } }
#use Carp​::Always;
if (1)
{
[]->();
}
__END__

Output​:
Not a CODE reference at try.pl line 7.
at try.pl line 3.
main​::__ANON__('Not a CODE reference at try.pl line 7.\x{a}')
called at try.pl line 5

Here only the last part "... called at try.pl line 5" is wrong.

I briefly tried to debug this with PERLDB_OPTS='NonStop=1' perl -d
try.pl, but
that makes the problem disappear.

Could this be related to #111982?

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 17, 2012

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

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 17, 2012

From @mauke

On 17.11.2012 20​:13, Father Chrysostomos via RT wrote​:

On Fri Nov 16 19​:07​:03 2012, mauke- wrote​:

This is a bug report for perl from l.mai@​web.de,
generated with the help of perlbug 1.39 running under perl 5.16.2.

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

I think the following is a bug in the core but I'm not sure what's
going on​:
#!perl
use strict;
use Carp​::Always;

if (1)
{
[]->();
}
__END__

Output​:
Not a CODE reference at try.pl line 5.

(Expected​: ... line 7.)

I can reproduce this with only core modules​:
#!perl
use strict;
BEGIN { use Carp (); $SIG{__DIE__} = sub { Carp​::croak @​_ } }
#use Carp​::Always;
if (1)
{
[]->();
}
__END__

Output​:
Not a CODE reference at try.pl line 7.
at try.pl line 3.
main​::__ANON__('Not a CODE reference at try.pl line 7.\x{a}')
called at try.pl line 5

Here only the last part "... called at try.pl line 5" is wrong.

I briefly tried to debug this with PERLDB_OPTS='NonStop=1' perl -d
try.pl, but
that makes the problem disappear.

Could this be related to #111982?

That bug is about some compilation errors (such as an undeclared
variable under 'use strict') having a caller location of end-of-script
(because perl performs some checks only after it has reached the end of
the code).

It doesn't seem to be immediately related because​:
- this is a runtime error, not compile time
- the bogus line number doesn't point to the end of the script
- in fact, it points to an *earlier* statement (the 'if' controlling the
block)

But maybe there's a deeper connection?

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 17, 2012

From @cpansprout

On Sat Nov 17 12​:28​:28 2012, mauke- wrote​:

On 17.11.2012 20​:13, Father Chrysostomos via RT wrote​:

Could this be related to #111982?

That bug is about some compilation errors (such as an undeclared
variable under 'use strict') having a caller location of end-of-script
(because perl performs some checks only after it has reached the end of
the code).

It doesn't seem to be immediately related because​:
- this is a runtime error, not compile time
- the bogus line number doesn't point to the end of the script
- in fact, it points to an *earlier* statement (the 'if' controlling the
block)

But maybe there's a deeper connection?

That was just a hunch, based on a quick reading. It’s probably unrelated.

In this case I suspect it has to do with a nextstate op being optimised
away so a different nextstate op is active. Again, I haven’t looked at
it carefully, as I am in the middle of fixing 5 more memory leaks I’ve
just discovered.

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 19, 2012

From @ikegami

On Sat, Nov 17, 2012 at 4​:12 PM, Father Chrysostomos via RT <
perlbug-followup@​perl.org> wrote​:

In this case I suspect it has to do with a nextstate op being optimised
away so a different nextstate op is active.

$ perl -MO=Concise -e'if (1)
{
  []->();
}
'
7 <@​> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 3 -e​:1) v​:{ ->3 <--- This is the one that is
used.
- <@​> scope vK ->7
- <0> ex-nextstate v ->3 <--- This would have the
correct info, but optimised away
6 <1> entersub[t1] vKS/TARG,1 ->7
- <1> ex-list K ->6
3 <0> pushmark s ->4
- <1> ex-rv2cv K ->-
5 <@​> anonlist sK* ->6
4 <0> pushmark s ->5
-e syntax OK

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 19, 2012

From @cpansprout

On Sun Nov 18 18​:09​:20 2012, ikegami@​adaelis.com wrote​:

On Sat, Nov 17, 2012 at 4​:12 PM, Father Chrysostomos via RT <
perlbug-followup@​perl.org> wrote​:

In this case I suspect it has to do with a nextstate op being optimised
away so a different nextstate op is active.

$ perl -MO=Concise -e'if (1)
{
[]->();
}
'
7 <@​> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 3 -e​:1) v​:{ ->3 <--- This is the one
that is
used.
- <@​> scope vK ->7
- <0> ex-nextstate v ->3 <--- This would have the
correct info, but optimised away
6 <1> entersub[t1] vKS/TARG,1 ->7
- <1> ex-list K ->6
3 <0> pushmark s ->4
- <1> ex-rv2cv K ->-
5 <@​> anonlist sK* ->6
4 <0> pushmark s ->5
-e syntax OK

Aha, so it looks as though pp_ctl.c​:pp_caller needs to use
util.c​:S_closest_cop.

Debugging without looking at the code seems to be working. :-)

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 1, 2013

From @cpansprout

Fixed in 2550212.

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 1, 2013

@cpansprout - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Sep 1, 2013
@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 1, 2013

From @cpansprout

On Sun Sep 01 11​:43​:04 2013, sprout wrote​:

Fixed in 2550212.

Though, actually, there are some cases where it doesn’t work, (e.g.,
eval "s{}\n{foo()}e"), because the context stack has no pointer to the
entersub op, but rather its ->op_next. Sometimes ->op_next is null (in
that subst example).

Would it be reasonable to put the entersub op in the context stack (as
retop) and have pp_leavesub do retop->op_next instead of just retop?

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 2, 2013

@cpansprout - Status changed from 'resolved' to 'open'

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

No branches or pull requests

1 participant