bug report: wrong line number if using built-in functions

bug report: wrong line number if using built-in functions

am 19.06.2008 19:05:57 von Christian Mehring

-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:

Line numbers will be wrong if a bulit-in function's first parameter is not
in the same line.

Minimized example:

01: #!/usr/local/bin/perl
02: use strict;
03: use warnings;
04:
05: abs
06:
07: 5;
08:
09: die __LINE__;
10:
11: __END__

Expected line is 9. Result is 11.

-> Warnings and dies give wrong line numbers. Finding errors is difficult
so.


2. Used Components and their Configuration:

*** mod_perl version 2.000002

*** using
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /Apache2/Bui
ldConfig.pm

*** Makefile.PL options:
MP_APR_CONFIG => /usr/bin/apr-1-config
MP_APR_LIB => aprext
MP_APXS => /usr/sbin/apxs
MP_COMPAT_1X => 1
MP_GENERATE_XS => 1
MP_LIBNAME => mod_perl
MP_USE_DSO => 1


*** The httpd binary was not found


*** (apr|apu)-config linking info

-laprutil-1 -lldap -llber -ldb-4.3 -lexpat
-lapr-1 -lpthread -ldl



*** /usr/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.6.18-53.1.4.el5,
archname=x86_64-linux-thread-multi
uname='linux dhcp6-189.pnq.redhat.com 2.6.18-53.1.4.el5 #1 smp wed
nov 14 10:37:27 est 2007 x86_64 x86_64 x86_64 gnulinux '
config_args='-des -Doptimize=-O2 -g -Dversion=5.8.8
-Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red
Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Dlibpth=/usr/local/lib64
/lib64 /usr/lib64 -Dprivlib=/usr/lib/perl5/5.8.8
-Dsitelib=/usr/lib/perl5/site_perl/5.8.8
-Dvendorlib=/usr/lib/perl5/vendor_perl/5.8.8
-Darchlib=/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi
-Dsitearch=/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thr ead-multi
-Dvendorarch=/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux -thread-mult
i -Darchname=x86_64-linux -Dvendorprefix=/usr -Dsiteprefix=/usr
-Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid
-Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog
-Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005
-Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto
-Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto
-Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r
_proto -Dinc_version_list=5.8.7 5.8.6 5.8.5 -Dscriptdir=/usr/bin'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=define uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-pipe -Wdeclaration-after-statement -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-O2 -g',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm'
ccversion='', gccversion='4.1.2 20070626 (Red Hat 4.1.2-14)',
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 =''
libpth=/usr/local/lib64 /lib64 /usr/lib64
libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread
-lc
perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-rpath,/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/ CORE'
cccdlflags='-fPIC', lddlflags='-shared -O2 -g'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP USE_64_BIT_ALL USE_64_BIT_INT
USE_ITHREADS USE_LARGE_FILES USE_PERLIO
USE_REENTRANT_API
Built under linux
Compiled at Feb 22 2008 01:27:07
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi
/usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi
/usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl/5.8.7
/usr/lib/perl5/site_perl/5.8.6
/usr/lib/perl5/site_perl/5.8.5
/usr/lib/perl5/site_perl
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi
/usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi
/usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8
/usr/lib/perl5/vendor_perl/5.8.7
/usr/lib/perl5/vendor_perl/5.8.6
/usr/lib/perl5/vendor_perl/5.8.5
/usr/lib/perl5/vendor_perl
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/5.8.8
.

*** Packages of interest status:

Apache2 : -
Apache2::Request : -
CGI : 3.15
ExtUtils::MakeMaker: 6.30
LWP : 5.805
mod_perl : -
mod_perl2 : 2.000002


3. This is the core dump trace: (if you get a core dump):

[CORE TRACE COMES HERE]

This report was generated by /usr/bin/mp2bug on Tue Jun 17 14:04:26 2008
GMT.

-------------8<---------- End Bug Report --------------8<----------

Note: Complete the rest of the details and post this bug report to
modperl perl.apache.org. To subscribe to the list send an empty
email to modperl-subscribe@perl.apache.org.

Re: bug report: wrong line number if using built-in functions

am 20.06.2008 00:40:02 von gozer

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig12D24BF430CC88515F4F154E
Content-Type: multipart/mixed;
boundary="------------010106050703040803010705"

This is a multi-part message in MIME format.
--------------010106050703040803010705
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable



Christian Mehring wrote:
> -------------8<---------- Start Bug Report ------------8<----------
> 1. Problem Description:
>=20
> Line numbers will be wrong if a bulit-in function's first parameter is =
not
> in the same line.
>=20
> Minimized example:
>=20
> 01: #!/usr/local/bin/perl
> 02: use strict;
> 03: use warnings;
> 04:
> 05: abs
> 06:
> 07: 5;
> 08:
> 09: die __LINE__;
> 10:
> 11: __END__
>=20
> Expected line is 9. Result is 11.
>=20
> -> Warnings and dies give wrong line numbers. Finding errors is difficu=
lt=20
> so.

I've been able to reproduce this problem, and it smells like it might be =
caused by the
optmizer rolling that statement into a single line...

I don't have time to look much into this, but I've attached a patch to th=
e test
case that illustrates the problem, in case anybody else want to have a sh=
ot at this.

--=20
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/

--------------010106050703040803010705
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="line.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
filename="line.diff"

Index: t/line.t
==================== =====3D=
==================== =====3D=
=================3D
--- t/line.t (revision 0)
+++ t/line.t (revision 0)
@@ -0,0 +1,35 @@
+use strict;
+use warnings FATAL =3D> 'all';
+
+use Apache::Test;
+use Apache::TestUtil qw(t_cmp t_catfile_apache t_client_log_error_is_exp=
ected);
+use Apache::TestRequest;
+use Apache::TestConfig ();
+
+my %modules =3D (
+ registry =3D> 'ModPerl::Registry',
+ registry_bb =3D> 'ModPerl::RegistryBB',
+ perlrun =3D> 'ModPerl::PerlRun',
+);
+
+my @aliases =3D sort keys %modules;
+
+my $vars =3D Apache::Test::config()->{vars};
+my $script_file =3D t_catfile_apache $vars->{serverroot}, 'cgi-bin', 'li=
ne.pl';
+
+plan tests =3D> @aliases * 1;
+
+# In some cases, looks like the optimizer throws off our line numbers
+# line nn filename doesn't seem to work all the time
+for my $alias (@aliases) {
+ my $url =3D "/$alias/line.pl";
+
+ ( my $cmdline =3D `$^X $script_file` ) =3D~ /(LINE:\d+)/;
+ my $line =3D $1;
+
+ ok t_cmp(
+ GET_BODY($url),
+ $line,
+ "$modules{$alias} basic cgi test",
+ );
+}
Index: t/cgi-bin/line.pl
==================== =====3D=
==================== =====3D=
=================3D
--- t/cgi-bin/line.pl (revision 0)
+++ t/cgi-bin/line.pl (revision 0)
@@ -0,0 +1,7 @@
+#!/usr/local/bin/perl
+print "Content-type: text/plain\n\n";
+my $abs =3D abs
+
+0; # Something funny happens to reported line numbers
+ # (optimizer playing with us here ?)=20
+print "LINE:" . __LINE__ ; # Should print '9'

--------------010106050703040803010705--

--------------enig12D24BF430CC88515F4F154E
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIWuBCyzKhB4jDpaURAjZnAJ0QG1zEM1ldywpB2F8exjglxFHkvACg vF3s
A9iaYZ5dp8k6hK5CY8QrAcQ=
=znwx
-----END PGP SIGNATURE-----

--------------enig12D24BF430CC88515F4F154E--