[phobos] Calling abort() on unhandled exception

Steve Schveighoffer schveiguy at yahoo.com
Fri Jul 30 03:44:19 PDT 2010


Wouldn't this be useless?  That is, do you care about a core dump when the stack 
is unwound (and the source of the problem is gone from the stack)?

If this is all you want, why not write your main that way?

BTW, my opinion is that an uncaught exception should not dump core.  It should 
print a stack trace and exit with non-zero exit code.  I understand the 
reasoning behind it, but dumping core is not a normal mode of operation for most 
users.  They don't know what to do with a core file, and silently dumping core 
on a system where one is not expecting it can fill up a filesystem.

-Steve



----- Original Message ----
> From: Leandro Lucarella <luca at llucax.com.ar>
> To: Discuss the phobos library for D 
><public-phobos-4o3eaN+cb9R8UrSeD/g0lQ at plane.gmane.org>
> Sent: Thu, July 29, 2010 11:20:55 PM
> Subject: Re: [phobos] Calling abort() on unhandled exception
> 
> 
> 
> Andrei Alexandrescu, el 29 de julio a las 19:51 me escribiste:
> >  Walter Bright wrote:
> > >I think we misunderstand each other. A file  copy program that
> > >fails due to, say, the disk being full, should not  produce a core
> > >dump. It should produce an error message  like:
> > >
> > >  error: disk full
> > >
> >  >An uncaught exception is NOT an invalid or crashed program in D.
> > 
> > I think Sean talks about Throwable objects that are not Exception  objects.
> 
> I think (and hope) he talks about bug 4385.
> 
> Please,  please, please, pretty please, call abort() at least on
> Linux, is what every  Linux programmer expects, I find debugging an
> accidentally uncaught exception  in D almost impossible.
> 
> Is not that bad for lazy people either, just add  4 lines to you main:
> 
> try {
> // program
> } catch (Exception e)  {
>         writeln(e);
> }
> 
> Or whatever. Add a  library function or an optional exception handler for
> people wanting to  shadow exceptions and make it look like a normal
> termination.
> 
> BTW,  *most Linux distributions don't dump cores by default* (you have to
> change  the ulimit to enable that feature, but if you run the program
> inside a  debugger, you'll get the exact backtrace where the exception
> was originally  thrown), so this doesn't mean that programs will be
> dumping cores all over  the places. I think part of the confusion about
> implying that calling abort()  will dump a core is because the title of
> the bug report is incorrect, what I  meant was uncaught exceptions should
> call abort() (and I'm changing it right  now). The runtime will probably
> print just "Aborted" by that is triggered by  SIGABRT, not abort(). So in
> a common Linux distribution, a D program that  exited because an uncaught
> exception will just print (no core  generated):
> error: disk full
> Aborted
> Which seems  reasonable.
> 
> Please also note that almost *ALL* programming languages  treats uncaught
> exception as errors and not normal program termination, most  even print
> a stack trace to show is a programming error.
> 
> [1]  http://d.puremagic.com/issues/show_bug.cgi?id=4385
> 
> -- 
> Leandro  Lucarella (AKA luca)                       http://llucax.com.ar/
> ----------------------------------------------------------------------
> GPG  Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A  8D05)
> ----------------------------------------------------------------------
> EXPOSICION  INTERNACIONAL DE INODOROS
>     -- Crónica  TV
> 
> _______________________________________________
> phobos mailing  list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos 


      


More information about the phobos mailing list