[phobos] Calling abort() on unhandled exception

Walter Bright walter at digitalmars.com
Thu Jul 29 19:37:51 PDT 2010


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.

Sean Kelly wrote:
> The error is still printed, I'm trying to create a core dump also. 
>
> Sent from my iPhone
>
> On Jul 29, 2010, at 5:07 PM, Walter Bright <walter at digitalmars.com> wrote:
>
>   
>> Unhandled exceptions should print the error message associated with the exception. This is so that, for example, you can write a file copy program without paying any attention to error messages. If an error happens, the program will print the right error message.
>>
>> Getting a core dump instead would be most unattractive.
>>
>> Sean Kelly wrote:
>>     
>>> (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?
>>>
>>>  
>>>       
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
>>     
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>
>   


More information about the phobos mailing list