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

This is a discussion on bug report: wrong line number if using built-in functions - modperl ; -------------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 ...

+ Reply to Thread
Results 1 to 2 of 2

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

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


    -------------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-thread-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

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



    Christian Mehring wrote:
    > -------------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.


    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 the test
    case that illustrates the problem, in case anybody else want to have a shot at this.

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

    Index: t/line.t
    ================================================== =================
    --- t/line.t (revision 0)
    +++ t/line.t (revision 0)
    @@ -0,0 +1,35 @@
    +use strict;
    +use warnings FATAL => 'all';
    +
    +use Apache::Test;
    +use Apache::TestUtil qw(t_cmp t_catfile_apache t_client_log_error_is_expected);
    +use Apache::TestRequest;
    +use Apache::TestConfig ();
    +
    +my %modules = (
    + registry => 'ModPerl::Registry',
    + registry_bb => 'ModPerl::RegistryBB',
    + perlrun => 'ModPerl::PerlRun',
    +);
    +
    +my @aliases = sort keys %modules;
    +
    +my $vars = Apache::Test::config()->{vars};
    +my $script_file = t_catfile_apache $vars->{serverroot}, 'cgi-bin', 'line.pl';
    +
    +plan tests => @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 = "/$alias/line.pl";
    +
    + ( my $cmdline = `$^X $script_file` ) =~ /(LINE:\d+)/;
    + my $line = $1;
    +
    + ok t_cmp(
    + GET_BODY($url),
    + $line,
    + "$modules{$alias} basic cgi test",
    + );
    +}
    Index: t/cgi-bin/line.pl
    ================================================== =================
    --- 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 = abs
    +
    +0; # Something funny happens to reported line numbers
    + # (optimizer playing with us here ?)
    +print "LINE:" . __LINE__ ; # Should print '9'

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

    iD8DBQFIWuBCyzKhB4jDpaURAjZnAJ0QG1zEM1ldywpB2F8exj glxFHkvACgvF3s
    A9iaYZ5dp8k6hK5CY8QrAcQ=
    =znwx
    -----END PGP SIGNATURE-----


+ Reply to Thread