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'

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to