[phobos] Calling abort() on unhandled exception

Sean Kelly sean at invisibleduck.org
Thu Jul 29 16:50:34 PDT 2010


(posted here because so few people read the druntime list)

I've been working on allowing core dumps to be created when an unhandled exception is thrown in a D app.  To avoid some weirdness that arises when an exception is thrown beyond the scope of (C) main() I'm calling abort() after terminating everything possible and reporting the exception.  What I'm wondering is whether this is an acceptable way to terminate a D app in this situation or if I should do something else.  I was looking at the Win32 docs for abort() and they're a bit weird:

    By default, the abort routine prints the message:

    "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information."

    It then calls raise(SIGABRT).

Even on OSX I see an "Abort trap" message in the console when I exit an app in this way.  I'm inclined to think that this isn't acceptable and that I should just try and sort out the weirdness that results from throwing an object outside of main(), but I thought I'd ask here for suggestions.  As an alternative I could call asm HLT, but this may bypass too much C-level runtime stuff.  Thoughts?


More information about the phobos mailing list