D Exceptions
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jan 26 12:36:35 PST 2010
Steven Schveighoffer wrote:
> On Tue, 26 Jan 2010 15:07:50 -0500, Nick Sabalausky <a at a.a> wrote:
>
>> "Daniel Keep" <daniel.keep.lists at gmail.com> wrote in message
>> news:hjn49d$2kfe$1 at digitalmars.com...
>>>
>>>
>>> Under linux, SIGSEGV is a signal, and you can't safely throw exceptions
>>> from signal handlers, so D just aborts.
>>>
>>
>> Just out of curiosity, is that a limitation that comes from the basic
>> concept of signals, or just a detail of how the OS just happens to do
>> signals?
>
> I think it's because a signal handler is entered at any point in the
> call stack. This means that to unwind the stack, you need to unwind
> possibly C functions and (I think) even system calls. The safest thing
> to do in a signal handler is to set a flag indicating a signal was
> recieved, and then asynchronously process it.
>
> Given that you could be in C or C++ land where exceptions either don't
> exist or are different, you face a very difficult task to unwind the
> stack correctly.
>
> -Steve
Yah it's the asynchrony of signals. Exceptions are synchronous, which
makes them a great deal simpler than they otherwise could.
Andrei
More information about the Digitalmars-d
mailing list