Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 527 forks source link

-B wrong line number after die #4693

Open p5pRT opened 22 years ago

p5pRT commented 22 years ago

Migrated from rt.perl.org#8051 (status was 'open')

Searchable as RT8051$

p5pRT commented 22 years ago

From Petr.Savicky@cuni.cz

The program​:

#!/usr/bin/perl
if (0) {die "aa";} elsif (1) {die "bb";}

gives the error message "bb at ./wrong.pl line 2."\, although it died at line 3.

Observed in perl-5.00503-10 (some Red Hat) and also perl-5.6.0-91 (SuSE Linux 7.2\, updated rpm for perl).

  Petr Savicky

p5pRT commented 22 years ago

From @schwern

On Thu\, Dec 13\, 2001 at 01​:20​:28AM +0100\, Petr.Savicky@​cuni.cz wrote​:

The program​:

#!/usr/bin/perl
if (0) {die "aa";} elsif (1) {die "bb";}

gives the error message "bb at ./wrong.pl line 2."\, although it died at line 3.

This is a known bug in the optimizer/opcodes. If you run B​::Deparse over that program you'll see perl compiles it down to just "die 'bb'"

$ perl -MO=Deparse ~/tmp/bug.plx die 'bb';; /home/schwern/tmp/bug.plx syntax OK

but the original line numbers are forgotten.

--

Michael G. Schwern \schwern@​pobox\.com http​://www.pobox.com/~schwern/ Perl Quality Assurance \perl\-qa@​perl\.org Kwalitee Is Job One Ooops\, fatal mutation in the test script.

p5pRT commented 22 years ago

From @jhi

----- Forwarded message from Kay Röpke \kroepke@​dolphin\-services\.de -----

Subject​: Re​: [ID 20011212.009] -B wrong line number after die From​: Kay Röpke \kroepke@​dolphin\-services\.de Date​: Thu\, 13 Dec 2001 01​:59​:00 +0100 Message-Id​: \983B5858\-EF64\-11D5\-ADB4\-000393414688@​dolphin\-services\.de To​: jhi@​iki.fi

Hi Jarkko!

Below is my reply to Bug Id 20011212.009. Could you please forward it to p5p as my f***ing provider messed up his mailserver.

Thanks\,

Kay Roepke

From​: Mail Delivery System \Mailer\-Daemon@​kundenserver\.de Date​: Don Dez 13\, 2001 01​:53​:17 AM Europe/Berlin To​: kay@​dolphin-services.de Subject​: Mail delivery failed​: returning message to sender

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to all of its recipients. The following address(es) failed​:

  perl5-porters@​perl.org​:   SMTP error from remote mailer after RCPT TO​:   \perl5\-porters@​perl\.org​:   host perlmail.valueclick.com [209.85.157.220]​:   553 Blackholed by ORDB -- see http​://ordb.org/lookup/?host=195.20.224.200

------ This is a copy of the message\, including all the headers. ------

Return-path​: \kay@​dolphin\-services\.de Received​: from [195.20.224.220] (helo=mrvdom04.kundenserver.de)   by moutvdom01.kundenserver.de with esmtp (Exim 2.12 #2)   id 16EK7U-0007Ch-00; Thu\, 13 Dec 2001 01​:53​:04 +0100 Received​: from p50870942.dip.t-dialin.net ([80.135.9.66] helo=kay.local)   by mrvdom04.kundenserver.de with esmtp (Exim 2.12 #2)   id 16EK7T-0001kV-00; Thu\, 13 Dec 2001 01​:53​:03 +0100 Date​: Thu\, 13 Dec 2001 01​:53​:11 +0100 Subject​: Re​: [ID 20011212.009] -B wrong line number after die Content-Type​: text/plain; charset=US-ASCII; format=flowed Mime-Version​: 1.0 (Apple Message framework v475) Cc​: perl5-porters@​perl.org To​: Petr.Savicky@​cuni.cz From​: =?ISO-8859-1?Q?Kay_R=F6pke?= \kay@​dolphin\-services\.de In-Reply-To​: \20011213012028\.A10934@​dec59\.ruk\.cuni\.cz Message-Id​: \C822FB62\-EF63\-11D5\-ADB4\-000393414688@​dolphin\-services\.de Content-Transfer-Encoding​: 7bit X-Mailer​: Apple Mail (2.475)

On Donnerstag\, Dezember 13\, 2001\, at 01​:20 AM\, Petr.Savicky@​cuni.cz wrote​:

The program​:

#!/usr/bin/perl if (0) {die "aa";} elsif (1) {die "bb";}

gives the error message "bb at ./wrong.pl line 2."\, although it died at line 3.

It actually did die in line 2​:

[kay​:\~] kroepke% perl -MO=Deparse #!/usr/bin/perl if (0) {die "aa";} elsif (1) {die "bb";}

die 'bb';; - syntax OK

The 'if (0) {die "aa";}' is optimized away\, thus it isn't visible for the tokenizer which thinks it's line #2.

I still think the line number should increase...I'm trudging through op.c right now. Anyone got a hint for me how to achieve that? (just for learning it..​:-))

Observed in perl-5.00503-10 (some Red Hat) and also perl-5.6.0-91 (SuSE Linux 7.2\, updated rpm for perl).

Still in my perl@​12958 (don't have anything else at hand right now).

Regards\,

Kay

----- End forwarded message -----

-- $jhi++; # http​://www.iki.fi/jhi/   # There is this special biologist word we use for 'stable'.   # It is 'dead'. -- Jack Cohen

p5pRT commented 22 years ago

From @schwern

On Thu\, Dec 13\, 2001 at 08​:30​:12AM +0100\, Petr.Savicky@​cuni.cz wrote​:

I am sorry for oversimplifying the example. The same bug appears in​:

#!/usr/bin/perl
if ($ARGV[0]) {die "aa";} elsif ($ARGV[1]) {die "bb";}

if it is run with command line parameters 0 1.

Interesting\, it appears to be totally dependent on whether there's any whitespace on the beginning of the second block.

These all die on line 2.

#!/usr/bin/perl
if ($ARGV[0]) {die "aa"} elsif ( $ARGV[1] ) {die "bb"}

#!/usr/bin/perl
if ($ARGV[0]) { die "aa" } elsif ( $ARGV[1] ) {die "bb"}

#!/usr/bin/perl
if ($ARGV[0]) { die "aa" } elsif ( $ARGV[1] ) {die "bb" }

But this gives the correct line 3.

#!/usr/bin/perl
if ($ARGV[0]) { die "aa" } elsif ( $ARGV[1] ) { die "bb"}

Probably some weird little optimizer bug.

--

Michael G. Schwern \schwern@​pobox\.com http​://www.pobox.com/~schwern/ Perl Quality Assurance \perl\-qa@​perl\.org Kwalitee Is Job One Right Wing Enema​: Flush Immorality Now! God gums gay gorgings.   -- boojum

p5pRT commented 22 years ago

From [Unknown Contact. See original ticket]

The program​:

#!/usr/bin/perl
if (0) {die "aa";} elsif (1) {die "bb";}

gives the error message "bb at ./wrong.pl line 2."\, although it died at line 3.

kay@​dolphin-services.de​:

The 'if (0) {die "aa";}' is optimized away\, thus it isn't visible for the tokenizer which thinks it's line #2.

schwern@​pobox.com​:

This is a known bug in the optimizer/opcodes. If you run B​::Deparse over that program you'll see perl compiles it down to just "die 'bb'"

I am sorry for oversimplifying the example. The same bug appears in​:

#!/usr/bin/perl
if ($ARGV[0]) {die "aa";} elsif ($ARGV[1]) {die "bb";}

if it is run with command line parameters 0 1.

  Petr Savicky

p5pRT commented 22 years ago

From [Unknown Contact. See original ticket]

Michael G Schwern wrote :

On Thu\, Dec 13\, 2001 at 08​:30​:12AM +0100\, Petr.Savicky@​cuni.cz wrote​:

I am sorry for oversimplifying the example. The same bug appears in​:

#!/usr/bin/perl
if ($ARGV[0]) {die "aa";} elsif ($ARGV[1]) {die "bb";}

if it is run with command line parameters 0 1.

Interesting\, it appears to be totally dependent on whether there's any whitespace on the beginning of the second block.

Correct\, the tokenizer increments the internal line counter for the op being compiled when it encounters whitespace. (Haven't I posted a similar answer to a similar question some weeks ago ?)