Front page | perl.perl5.porters |
Postings from April 2000
[ID 20000405.013] Bug in Carp::Heavy?
From:
Richard Foley
Date:
April 5, 2000 07:35
Subject:
[ID 20000405.013] Bug in Carp::Heavy?
Message ID:
38EB4F00.40B08ECB@m.dasa.de
=== forwarded message ===
I'm not sure if this is a bug or what.
BTW, I tried sending a bug report twice and it didn't go through so
instead I'll send a patch.
Anyway, under 5.6.0 it seems that the results of caller have changed ever
so slightly. Previously, when eval'ing a block {} (caller(0))[6]
(evaltext) was not returned at all (it returned a 5 elements list). Under
perl5.6.0 it now returns 0. This caused a problem in
Carp::Heavy::longmess which made it print stuff like a require had
happened.
Here's a quick test script that illustrates the issue (compare under
5.00503 to 5.6.0):
use Carp;
eval {
print join ' ', map {defined $_ ? $_ : 'undef'} caller(0);
print "\n";
confess 'foo';
};
print $@;
Here's a patch:
--- /usr/local/lib/perl5/5.6.0/Carp/H Tue Apr 4 23:10:47 2000
+++ /usr/local/lib/perl5/5.6.0/Carp/Heavy.pm Tue Apr 4 23:17:56 2000
@@ -58,7 +58,7 @@
} else {
# Build a string, $sub, which names the sub-routine called.
# This may also be "require ...", "eval '...' or "eval {...}"
- if (defined $eval) {
+ if ($eval) {
if ($require) {
$sub = "require $eval";
} else {
The only problem (and it's not much of one) is that if you were to do:
$SIG{__DIE__} = sub { confess(@_) };
and then do:
eval '0';
and that eval caused a fatal error (dunno how though) it might cause Carp
to report incorrectly. OTOH, I think that's a heck of a rare special
case. OTOH (yes, I have 3) maybe the Perl core needs to be changed to
revert to the previous behavior of returning a 5 element list.
and here's my perl -V:
Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
Platform:
osname=linux, osvers=2.2.5-15, archname=i586-linux
uname='linux urth.org 2.2.5-15 #15 mon jul 5 01:48:48 cdt 1999 i586
unknown '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define
use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
Compiler:
cc='cc', optimize='-O2', gccversion=2.95.1 19990816 (release)
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64'
stdchar='char', d_stdstdio=define, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=/lib/libc-2.1.1.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at Mar 23 2000 12:04:27
@INC:
/usr/local/lib/perl5/5.6.0/i586-linux
/usr/local/lib/perl5/5.6.0
/usr/local/lib/perl5/site_perl/5.6.0/i586-linux
/usr/local/lib/perl5/site_perl/5.6.0
/usr/local/lib/perl5/site_perl
.
/*==================
www.urth.org
We await the New Sun
==================*/
-
[ID 20000405.013] Bug in Carp::Heavy?
by Richard Foley