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 syntax error message #9991

Closed
p5pRT opened this issue Nov 28, 2009 · 7 comments
Closed

wrong line number in syntax error message #9991

p5pRT opened this issue Nov 28, 2009 · 7 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Nov 28, 2009

Migrated from rt.perl.org#70910 (status was 'resolved')

Searchable as RT70910$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 28, 2009

From frank.wiegand@gmail.com

This is a bug report for perl from frank.wiegand@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.11.2.


  $ bleadperl -e '+'
  syntax error at -e line 2, at EOF
  Execution of -e aborted due to compilation errors.

This broke between 5.11.0 and 5.11.2, git bisect reports​:

f0e67a1 is the first bad commit
commit f0e67a1
Author​: Zefram <zefram@​fysh.org>
Date​: Sun Nov 15 14​:25​:50 2009 +0100

  lexer API

  Attached is a patch that adds a public API for the lowest layers of
  lexing. This is meant to provide a solid foundation for the parsing that
  Devel​::Declare and similar modules do, and it complements the pluggable
  keyword mechanism. The API consists of some existing variables combined
  with some new functions, all marked as experimental (which making them
  public certainly is).

:100644 100644 22db6a3c9011829aff5176a7bacd4373f9c1d354 b8073eb771a2c615c876970bc1883bd4316cc88c M MANIFEST
:100644 100644 7522055a288adf11291c654a30726bd618c11f25 f17f7ada0a8c023af12e8aa9b7800f9ccf643df5 M embed.fnc
:100644 100644 52e40c6fa2f68c4c009a83d7669522543a9baad1 17bf11a5139254f0a5f6a46473bb136d1c145259 M embed.h
:040000 040000 23226494a6184590278d718527f383b69fff2cf3 6ebec696e22c1a6f7b1b4043db5a090006e9f1b1 M ext
:100644 100644 6000af755912fcd939cbe94d4662c54dd42acd5b 6a44049c4e4262b09ae4c5a0d2fd2d9749f12189 M global.sym
:100644 100644 74d8ef2197b15a99ce10a233a2f829c286043022 462dcfdef806826927c7e9c5261e46e57033960c M parser.h
:100644 100644 3639bd6ac0f26afd8537e3e9722382c2ba5beea2 3d378917c94e26aa9a550c181fdd824d6aad2e60 M perlvars.h
:040000 040000 79cfd550ba3c1ee290da3a30115bcade3d31effb 4de6df320a87c92b6db4c4df6a5b3cbace2d96bb M pod
:100644 100644 f1ab3d022e76840708a2367ea74a652b299bd6f1 fd2eb36cd42cecae815240f00f301038d0aba9fc M proto.h
:100644 100644 b8abbd854f001057679312ed03b534e0853cf490 6793f7b8669efb9df31731d9eff7507d6672c9b6 M toke.c

Frank



Flags​:
  category=core
  severity=low


Site configuration information for perl 5.11.2​:

Configured by fw at Sat Nov 28 22​:03​:13 CET 2009.

Summary of my perl5 (revision 5 version 11 subversion 2) configuration​:
  Commit id​: 17c59fd
  Platform​:
  osname=linux, osvers=2.6.30-2-amd64, archname=x86_64-linux
  uname='linux hal2 2.6.30-2-amd64 #1 smp fri sep 25 22​:16​:56 utc 2009 x86_64 gnulinux '
  config_args='-des -Dusedevel -Doptimize=-g -Dcc=ccache gcc -Dld=gcc'
  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
  Compiler​:
  cc='ccache gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-g',
  cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.3.4', 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='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
  libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=/lib/libc-2.10.1.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.10.1'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib -fstack-protector'

Locally applied patches​:
 


@​INC for perl 5.11.2​:
  lib
  /usr/local/lib/perl5/site_perl/5.11.2/x86_64-linux
  /usr/local/lib/perl5/site_perl/5.11.2
  /usr/local/lib/perl5/5.11.2/x86_64-linux
  /usr/local/lib/perl5/5.11.2
  .


Environment for perl 5.11.2​:
  HOME=/home/cpan
  LANG=C
  LANGUAGE=
  LC_ALL=C
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=~/bin​:/usr/local/bin​:/usr/bin​:/bin​:/usr/local/games​:/usr/games
  PERL_AUTOINSTALL=--defaultdeps
  PERL_BADLANG (unset)
  PERL_EXTUTILS_AUTOINSTALL=--defaultdeps
  PERL_MM_USE_DEFAULT=1
  SHELL=/bin/bash

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 30, 2009

From zefram@fysh.org

Frank Wiegand wrote​:

$ bleadperl -e '+'
syntax error at -e line 2, at EOF

Bah, that's another area where I tested a bunch of variations while
developing the patch, but apparently missed some. I'll look into it.

-zefram

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 30, 2009

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

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 9, 2009

From zefram@fysh.org

Frank Wiegand wrote​:

$ bleadperl -e '+'
syntax error at -e line 2, at EOF

Fixed by the attached patch.

-zefram

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 9, 2009

From zefram@fysh.org

Inline Patch
diff --git a/MANIFEST b/MANIFEST
index a85d318..43e9a49 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4187,6 +4187,7 @@ t/comp/bproto.t			See if builtins conform to their prototypes
 t/comp/cmdopt.t			See if command optimization works
 t/comp/colon.t			See if colons are parsed correctly
 t/comp/decl.t			See if declarations work
+t/comp/final_line_num.t		See if line numbers are correct at EOF
 t/comp/fold.t			See if constant folding works
 t/comp/hints.aux		Auxillary file for %^H test
 t/comp/hints.t			See if %^H works
diff --git a/t/comp/final_line_num.t b/t/comp/final_line_num.t
new file mode 100644
index 0000000..bb06847
--- /dev/null
+++ b/t/comp/final_line_num.t
@@ -0,0 +1,13 @@
+#!./perl
+
+BEGIN { print "1..1\n"; }
+
+BEGIN { $SIG{__DIE__} = sub {
+	$_[0] =~ /\Asyntax error at [^ ]+ line ([0-9]+), at EOF/ or exit 1;
+	my $error_line_num = $1;
+	print $error_line_num == $last_line_num ? "ok 1\n" : "not ok 1\n";
+	exit 0;
+}; }
+
+# the next line causes a syntax error at end of file, to be caught above
+BEGIN { $last_line_num = __LINE__; } print 1+
diff --git a/toke.c b/toke.c
index d498a34..2ec5f2d 100644
--- a/toke.c
+++ b/toke.c
@@ -4363,7 +4363,8 @@ Perl_yylex(pTHX)
 		    PL_doextract = FALSE;
 		}
 	    }
-	    incline(s);
+	    if (PL_rsfp)
+		incline(s);
 	} while (PL_doextract);
 	PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = s;
 	PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 9, 2009

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

@p5pRT p5pRT closed this as completed Dec 9, 2009
@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 9, 2009

From @obra

Thanks. Applied as 85613ca

On Wed, Dec 09, 2009 at 10​:08​:33PM +0000, Zefram wrote​:

Frank Wiegand wrote​:

$ bleadperl -e '+'
syntax error at -e line 2, at EOF

Fixed by the attached patch.

-zefram

diff --git a/MANIFEST b/MANIFEST
index a85d318..43e9a49 100644
--- a/MANIFEST
+++ b/MANIFEST
@​@​ -4187,6 +4187,7 @​@​ t/comp/bproto.t See if builtins conform to their prototypes
t/comp/cmdopt.t See if command optimization works
t/comp/colon.t See if colons are parsed correctly
t/comp/decl.t See if declarations work
+t/comp/final_line_num.t See if line numbers are correct at EOF
t/comp/fold.t See if constant folding works
t/comp/hints.aux Auxillary file for %^H test
t/comp/hints.t See if %^H works
diff --git a/t/comp/final_line_num.t b/t/comp/final_line_num.t
new file mode 100644
index 0000000..bb06847
--- /dev/null
+++ b/t/comp/final_line_num.t
@​@​ -0,0 +1,13 @​@​
+#!./perl
+
+BEGIN { print "1..1\n"; }
+
+BEGIN { $SIG{__DIE__} = sub {
+ $_[0] =~ /\Asyntax error at [^ ]+ line ([0-9]+), at EOF/ or exit 1;
+ my $error_line_num = $1;
+ print $error_line_num == $last_line_num ? "ok 1\n" : "not ok 1\n";
+ exit 0;
+}; }
+
+# the next line causes a syntax error at end of file, to be caught above
+BEGIN { $last_line_num = __LINE__; } print 1+
diff --git a/toke.c b/toke.c
index d498a34..2ec5f2d 100644
--- a/toke.c
+++ b/toke.c
@​@​ -4363,7 +4363,8 @​@​ Perl_yylex(pTHX)
PL_doextract = FALSE;
}
}
- incline(s);
+ if (PL_rsfp)
+ incline(s);
} while (PL_doextract);
PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = s;
PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);

--

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