[phobos] Calling abort() on unhandled exception

Leandro Lucarella luca at llucax.com.ar
Thu Jul 29 20:27:34 PDT 2010



Michel Fortin, el 29 de julio a las 22:26 me escribiste:
> Le 2010-07-29 à 21:52, Sean Kelly a écrit :
> 
> > Huh, so the ObjC behavior is to print the exception and abort() too. 
> 
> Mostly. Actually, it seems it calls the C++ runtime's std::terminate,
> which in turns call a user-settable handler function which is abort()
> if you haven't changed it.

GCC uses a custom termination handler that prints the exception and then
calls abort(), see:
http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt02ch06s02.html

> > Looks like good justification for doing it in D as well then. 
> 
> 
> I think it's the right thing to do, for OSX at least.

In Linux too, and probably any POSIX compatible OS.

> Perhaps it could be useful if the programmer could substitute his own
> handler function (similar to what you can do with std::set_terminate
> in C++) if he wants to do something special (such as a core dump).

abort() will dump a core if you set ulimit for core size bigger than
what the core of your program is. Try this (using sh/bash):
$ ulimit -c unlimited
$ sleep 60 &
$ kill -ABRT $!

You will get a core. Or just try running it from GDB without setting
ulimit, you'll get to inspect the program exactly where it was
interrupted by the signal.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Y2K
<Aztech_> hmm, nothing major has happend, what an anticlimax
<CaPS> yeah
<CaPS> really sucks
<CaPS> I expected for Australia to sink into the sea or something
<CaPS> but nnoooooooo



More information about the phobos mailing list