develooper Front page | perl.perl5.porters | Postings from September 2009

[PATCH] Fix for spurious error report from utf8_heavy

Thread Next
From:
Salvador Ortiz Garcia
Date:
September 15, 2009 13:58
Subject:
[PATCH] Fix for spurious error report from utf8_heavy
Message ID:
1253048307.31824.119.camel@monica.msg.com.mx
Dear p5p,

I found a bug in utf8_heavy.pl: it is using $@ without localizing it,
patch attached.

The case history:

By mistake I introduced in a package of my program a typo ($bdh vs $dbh)
but the error generated only reads: 

'Compilation error at /usr/lib/perl5/5.10.0/utf8_heavy.pl line 198,...'

After a couple hours of debugging (checking caller() inside SWASHNEW,
etc.), I found that the message was triggered by some regex code a few
lines _after_ my real error (24 lines in my concrete case).

Commenting out the line with the regex makes my mistake evident, now the
error correctly reads:

'Global symbol "$dbh" requires explicit package name ...'

Somehow the parser continues after the real error and when SWASHNEW is
called because of the regex, the _previous_ error condition was noted by
line 198 of utf8_heavy.pl in the "if $@" part of
 
  $list = do $file; die $@ if $@;

but the real error message was masqueraded.

I don't known exactly why the real error was masqueraded or why the
parser continues too much but using $@ in SWASHNEW without localizing it
its a bug IMHO.

I can't reproduce the bug in a small test case, but after applying the
attached patch the spurious error doesn't show any more.

Any comments?

Regards.

Salvador Ortiz.



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About