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

[PATCH] Fix for spurious error report from utf8_heavy

Thread Next
Salvador Ortiz Garcia
September 15, 2009 13:58
[PATCH] Fix for spurious error report from utf8_heavy
Message ID:
Dear p5p,

I found a bug in 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/ 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 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?


Salvador Ortiz.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About