[phobos] Calling abort() on unhandled exception

Michel Fortin michel.fortin at michelf.com
Fri Jul 30 18:38:28 PDT 2010


Le 2010-07-30 à 20:38, Andrei Alexandrescu a écrit :

> Leandro Lucarella wrote:
>> Calling abort() on Linux will simply print "Aborted". Do you think is
>> that bad that worth being completely different than any other PL and
>> making debug an uncaught exception almost imposible???
> 
> What is impossible about writing one try statement?

If you have a debugger hooked, abort() will cause the debugger to stop the program in the state it currently is. If an uncaught exception doesn't unwind the stack and instead calls abort(), the debugger will stop the program exactly in the state the exception was thrown, not in a state where everything has been cleaned up and no clues as to what happened are left.

It's like in the real world if you see a crime happen: don't clean up before calling the police, I guaranty the inspector won't appreciate. An uncaught exception is an error not expected by the programmer, it requires investigation to ensure the program's correctness. This investigation might not be worth it if it happens in a simple script, but to help debug a big program you shouldn't unwind the stack before calling abort().

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the phobos mailing list