Bug in line-number reporting? 
Author Message
 Bug in line-number reporting?

[ bug-mail.d 2K ]
Dear all,

I use perl 5.002, and i found what seems like a bug in the
line-number reporting mechanism.

If the attached script is run as-is, it gives
"divide-by-zero" error messages with wrong line numbers
(numbers that refer to the enclosing if()'s, where present).

=> $ ./test.pl
=> &if_else(): Illegal division by zero at ./test.pl line 29.
=>         ...caught at ./test.pl line 22.
=> &if_return(): Illegal division by zero at ./test.pl line 44.
=>         ...caught at ./test.pl line 23.
=> &if_if(): Illegal division by zero at ./test.pl line 53.
=>         ...caught at ./test.pl line 24.
=> $

If the "print STDERR ... __LINE__ ..."'s are de-commented,
the bug goes away.

I put the calls inside eval()'s, so that i'll get a chance to
try all three code-flows in one run.

Please help.  Thanks.

----------------------8<----------------------8<----------------------
#!/usr/local/bin/perl -w

# Intention: trying to reproduce the bug in divide-by-zero error reporting.
#
# $Source: /u/ahimsa/ksundar/vlog/data/pliopt.failures/bench-proc/RCS/test.pl,v $
# $Revision: 1.4 $; $State: Exp $; $Date: 1998/05/15 16:36:56 $
# Original author:      Kripa Sundar
# $Author: ksundar $; $Locker: ksundar $

# Wild perl bug:
# If the "print STDERR ... __LINE__ ..."'s are kept commented, error
#   reporting for divide-by-zero gives line numbers that refer to the if().
# The bug goes away if the lines are de-commented, even though those
#   print()'s are never going to get executed, because of the
#   conditionals.


    , $she_sells_seashells++ if $she_sells_seashells; # Keep "-w" happy.

($nt, $bt) = (0, 1);

eval "&if_else"; warn $!;
eval "&if_return"; warn $!;
eval "&if_if"; warn $!;
exit;

sub if_else {
    print STDERR "&if_else(): ";
    if ($nt eq "--") {
        print "ERROR";
    } else {
        #print STDERR "(line# ", __LINE__, ") " if $fNeverTrue;
        print $bt/$nt;
    }

Quote:
} # &if_else()

sub if_return {
    print STDERR "&if_return(): ";
    if ($nt eq "--") {
        print "ERROR";
        return;
    }
    #print STDERR "(line# ", __LINE__, ") " if $fNeverTrue;
    print $bt/$nt;

Quote:
} # &if_return()

sub if_if {
    print STDERR "&if_if(): ";
    if ($nt eq "--") {
        print "ERROR";
        return;
    }
    if ($nt < 555) {
        #print STDERR "(line# ", __LINE__, ") " if $fNeverTrue;
        print $bt/$nt;
    }
Quote:
} # &if_if()

----------------------8<----------------------8<----------------------

peace,
--kripA



Tue, 31 Oct 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Perl line numbers vs Apache error_log reported numbers?

2. BUG REPORT: bug with subroutines an

3. Perl bug? Wrong line number given in $@

4. extract numbers from report-best method?

5. Randomly selecting lines by line number

6. extract numbers from col/row report

7. displaying lines with a specific number of lines on each page

8. Searching a WORD 6 DOC by line line number

9. Is anyone tracking Bug reports for Perl5.000

10. PERL 5.000 bug report (FORMATs from 4.036 to 5.000)

11. Reporting bugs in Perl 5.000

12. Bug reporting for manual pages

 

 
Powered by phpBB® Forum Software