Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DESTROY silences failures #8336

Closed
p5pRT opened this issue Feb 13, 2006 · 5 comments
Closed

DESTROY silences failures #8336

p5pRT opened this issue Feb 13, 2006 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 13, 2006

Migrated from rt.perl.org#38513 (status was 'rejected')

Searchable as RT38513$

@p5pRT
Copy link
Author

p5pRT commented Feb 13, 2006

From stas@stason.org

Created by stas@localhost.mailchannels.com

The problem​: DESTROY silences any errors, consider​:

perl -le '$y = 0; $x = 5; $z = $x/$y;'
Illegal division by zero at -e line 1.

Now the same in DESTROY​:

perl -le ' package A; sub new { bless \{}, "A"}; my $a = A->new; sub
DESTROY { $y = 0; $x = 5; $z = $x/$y; }'

That's nasty especially if you run an essential clean up code in it.

Indeed, you get the message if you enable 'warnings'​:

perl -le 'use warnings; package A; sub new { bless \{}, "A"}; my $a =
A->new; sub DESTROY { my $y = 0; my $x = 5; my $z = $x/$y; }'
  (in cleanup) Illegal division by zero at -e line 1.

I remember something about perl trying not die in DESTROY, but I can't see
why warnings need to be enabled in order to get that fatal error reduced
to the warning, be reported.

Moreover, if you have FATAL enabled, you get no warning/error whatsoever.

perl -le 'use warnings FATAL => 'all'; package A; sub new { bless \{},
"A"}; my $a = A->new; sub DESTROY { my $y = 0; my $x = 5; my $z = $x/$y; }'

Perl Info

Flags:
     category=core
     severity=high

Site configuration information for perl v5.8.7:

Configured by stas at Mon Jan 16 13:12:34 PST 2006.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
   Platform:
     osname=linux, osvers=2.6.12-12mdksmp, archname=i686-linux-thread-multi
     uname='linux localhost 2.6.12-12mdksmp #1 smp fri sep 9 17:43:23 cest 
2005 i686 intel(r) pentium(r) 4 cpu 2.80ghz unknown gnulinux '
     config_args='-des -Dprefix=/home/stas/perl/5.8.7-ithread -Dusethreads 
-Doptimize=-g -Duseshrplib -Dusedevel -Accflags=-DPERL_EMERGENCY_SBRK 
-DDEBUG_LEAKING_SCALARS'
     hint=recommended, useposix=true, d_sigaction=define
     usethreads=define use5005threads=undef useithreads=define 
usemultiplicity=define
     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
     use64bitint=undef use64bitall=undef uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS 
-DPERL_EMERGENCY_SBRK -DDEBUG_LEAKING_SCALARS -DDEBUGGING 
-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64',
     optimize='-g',
     cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS 
-DPERL_EMERGENCY_SBRK -DDEBUG_LEAKING_SCALARS -DDEBUGGING 
-fno-strict-aliasing -pipe -I/usr/local/include'
     ccversion='', gccversion='4.0.1 (4.0.1-5mdk for Mandriva Linux 
release 2006.0)', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
     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, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -L/usr/local/lib'
     libpth=/usr/local/lib /lib /usr/lib
     libs=-lnsl -lndbm -lgdbm -ldl -lm -lcrypt -lutil -lpthread -lc
     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
     libc=/lib/libc-2.3.5.so, so=so, useshrplib=true, libperl=libperl.so
     gnulibc_version='2.3.5'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E 
-Wl,-rpath,/home/stas/perl/5.8.7-ithread/lib/5.8.7/i686-linux-thread-multi/CORE'
     cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:



@INC for perl v5.8.7:
     /home/stas/perl/5.8.7-ithread/lib/5.8.7/i686-linux-thread-multi
     /home/stas/perl/5.8.7-ithread/lib/5.8.7
     /home/stas/perl/5.8.7-ithread/lib/site_perl/5.8.7/i686-linux-thread-multi
     /home/stas/perl/5.8.7-ithread/lib/site_perl/5.8.7
     /home/stas/perl/5.8.7-ithread/lib/site_perl
     .


Environment for perl v5.8.7:
     HOME=/home/stas
     LANG=en_GB
     LANGUAGE=en_GB:en
     LC_ADDRESS=en_CA
     LC_COLLATE=en_GB
     LC_CTYPE=en_GB
     LC_IDENTIFICATION=en_CA
     LC_MEASUREMENT=en_CA
     LC_MESSAGES=en_GB
     LC_MONETARY=en_CA
     LC_NAME=en_CA
     LC_NUMERIC=en_CA
     LC_PAPER=en_CA
     LC_SOURCED=1
     LC_TELEPHONE=en_CA
     LC_TIME=en_GB
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
 
PATH=/usr/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/usr/lib/jdk-1.5.0.4/jre/bin:/usr/lib/jdk-1.5.0.4/bin:/home/stas/bin:/home/stas/bin:/usr/local/bin:/usr/X11R6/bin:/usr/java/j2re1.4.0/bin/
     PERLDOC_PAGER=less -R
     PERL_BADLANG (unset)
     SHELL=/bin/tcsh

-- 
_____________________________________________________________
Stas Bekman mailto:stas@stason.org  http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book       http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/


@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

From @doy

This is working as intended. Consider​:

  eval { my $obj = Thinger->new; $obj->do_something_important }

If do_something_important dies, you probably want to see that exception.
However, the process of throwing that exception will leave the scope of
the eval, causing Thinger->DESTROY to be called. If DESTROY throws an
exception, which one should end up in $@​? Perl has chosen (as most other
languages have) that the original exception should be the one that is
used, and not the exception thrown from the destructor. Having
exceptions in destructors sometimes work and sometimes not is a worse
situation than having them never work, so they are silenced in all cases
rather than only when another exception is pending. In general, you
should avoid doing things in destructors that can cause exceptions.

If nobody objects, I will close this ticket in a few days.

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 9, 2016

From @dcollinsn

Working as intended, no objections to Jesse's suggestion to close. Rejected.

@p5pRT
Copy link
Author

p5pRT commented Jul 9, 2016

@dcollinsn - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant