develooper Front page | perl.perl5.porters | Postings from August 2001

[ID 20010822.007] eval STRING & diagnostics.pm not mixing

From:
schwern
Date:
August 22, 2001 13:03
Subject:
[ID 20010822.007] eval STRING & diagnostics.pm not mixing
Message ID:
20010822200300.0D1638253@ool-18b93024.dyn.optonline.net
This is a bug report for perl from schwern@pobox.com,
generated with the help of perlbug 1.33 running under perl v5.6.1.


-----------------------------------------------------------------
[Please enter your report here]

    use diagnostics;
    use base qw(I::do::not::exist);

This vomits:

Uncaught exception from user code:
        Uncaught exception from user code:
        Uncaught exception from user code:
        Can't locate I/do/not/exist.pm in @INC (@INC contains: /home/schwern/lib/site_perl /usr/lib/perl5 /usr/local/lib/site_perl /usr/local/bleadperl/lib/5.7.2/ppc-linux-64int /usr/local/bleadperl/lib/5.7.2 /usr/local/bleadperl/lib/site_perl/5.7.2/ppc-linux-64int /usr/local/bleadperl/lib/site_perl/5.7.2 /usr/local/bleadperl/lib/site_perl /usr/local/lib/site_perl .) at (eval 2) line 3.
        eval {...} called at /usr/local/bleadperl/lib/5.7.2/base.pm line 60
        base::import('base','I::do::not::exist') called at - line 2
        main::BEGIN() called at I/do/not/exist.pm line 0
        eval {...} called at I/do/not/exist.pm line 0
        ...propagated at /usr/local/bleadperl/lib/5.7.2/base.pm line 63.
        base::import('base','I::do::not::exist') called at - line 2
        main::BEGIN() called at /usr/local/bleadperl/lib/5.7.2/base.pm line 2
        eval {...} called at /usr/local/bleadperl/lib/5.7.2/base.pm line 2
BEGIN failed--compilation aborted at - line 2.

Problem occurs in 5.004_05, 5.6.1 and bleadperl.


Looks like a mistake in death_trap().  I don't see why it continues
processing if you're inside an eval.  Patch follows (with tests!)
I also explained the $SIG{__DIE__} = $SIG{__WARN__} = '' a bit better.

--- lib/diagnostics.pm	2001/08/22 19:52:33	1.1
+++ lib/diagnostics.pm	2001/08/22 20:00:42
@@ -476,11 +476,18 @@
     if (caller eq $WHOAMI) { print STDERR "INTERNAL EXCEPTION: $exception"; } 
     &$olddie if defined $olddie and $olddie and $olddie ne \&death_trap;
 
+    return if $in_eval;
+
     # We don't want to unset these if we're coming from an eval because
-    # then we've turned off diagnostics. (Actually what does this next
-    # line do?  -PSeibel)
-    $SIG{__DIE__} = $SIG{__WARN__} = '' unless $in_eval;
+    # then we've turned off diagnostics.
+
+    # Switch off our die/warn handlers so we don't wind up in our own
+    # traps.
+    $SIG{__DIE__} = $SIG{__WARN__} = '';
+
+    # Have carp skip over death_trap() when showing the stack trace.
     local($Carp::CarpLevel) = 1;
+
     confess "Uncaught exception from user code:\n\t$exception";
 	# up we go; where we stop, nobody knows, but i think we die now
 	# but i'm deeply afraid of the &$olddie guy reraising and us getting
--- lib/diagnostics.t	2001/08/22 19:54:31	1.1
+++ lib/diagnostics.t	2001/08/22 19:58:40
@@ -5,34 +5,14 @@
     @INC = 'lib';
 }
 
+use Test::More tests => 2;
 
-######################### We start with some black magic to print on failure.
+BEGIN { use_ok('diagnostics') }
 
-# Change 1..1 below to 1..last_test_to_print .
-# (It may become useful if the test is moved to ./t subdirectory.)
-use strict;
-use warnings;
+require base;
 
-use vars qw($Test_Num $Total_tests);
+eval {
+    'base'->import(qw(I::do::not::exist));
+};
 
-my $loaded;
-BEGIN { $| = 1; $Test_Num = 1 }
-END {print "not ok $Test_Num\n" unless $loaded;}
-print "1..$Total_tests\n";
-BEGIN { require diagnostics; } # Don't want diagnostics' noise yet.
-$loaded = 1;
-ok($loaded, 'compile');
-######################### End of black magic.
-
-sub ok {
-	my($test, $name) = shift;
-	print "not " unless $test;
-	print "ok $Test_Num";
-	print " - $name" if defined $name;
-	print "\n";
-	$Test_Num++;
-}
-
-
-# Change this to your # of ok() calls + 1
-BEGIN { $Total_tests = 1 }
+is( $@, '',   'diagnostics not tripped up by "use base qw(Dont::Exist)"' );



[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=low
---
Site configuration information for perl v5.6.1:

Configured by bod at Fri Jun 22 19:29:41 EST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.4.5-pre3, archname=powerpc-linux
    uname='linux vir 2.4.5-pre3 #1 mon jun 18 15:58:49 est 2001 ppc unknown '
    config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=powerpc-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.1 -Darchlib=/usr/lib/perl/5.6.1 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.1 -Dsitearch=/usr/local/lib/perl/5.6.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Dotherlibdirs=/usr/lib/perl5/5.6:/usr/lib/perl5/5.005 -Duseshrplib -Dlibperl=libperl.so.5.6.1 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.4 20010604 (Debian prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldbm -ldb -ldl -lm -lc -lcrypt
    perllibs=-ldl -lm -lc -lcrypt
    libc=/lib/libc-2.2.3.so, so=so, useshrplib=true, libperl=libperl.so.5.6.1
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.6.1:
    /home/schwern/lib/site_perl/powerpc-linux
    /home/schwern/lib/site_perl
    /usr/lib/perl5/powerpc-linux
    /usr/lib/perl5/5.005
    /usr/lib/perl5
    /usr/local/lib/site_perl/powerpc-linux
    /usr/local/lib/site_perl
    /usr/local/lib/perl/5.6.1
    /usr/local/share/perl/5.6.1
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.6.1
    /usr/share/perl/5.6.1
    /usr/local/lib/site_perl/powerpc-linux
    /usr/local/lib/site_perl
    /usr/local/share/perl/5.6.0
    /usr/lib/perl5/5.6/powerpc-linux
    /usr/lib/perl5/5.6
    /usr/lib/perl5/5.005/powerpc-linux
    /usr/lib/perl5/5.005
    .

---
Environment for perl v5.6.1:
    HOME=/home/schwern
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/schwern/bin:/home/schwern/sbin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/X11/bin:/usr/bin/X11:/usr/games
    PERL5LIB=/home/schwern/lib/site_perl:/usr/lib/perl5:/usr/local/lib/site_perl
    PERL_BADLANG (unset)
    SHELL=/bin/bash




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