D - Unsafe and doomed
alex burton
alexibu.remove at me.com
Tue Jan 7 04:51:50 PST 2014
On Tuesday, 7 January 2014 at 11:36:50 UTC, Ola Fosheim Grøstad
wrote:
> On Tuesday, 7 January 2014 at 11:29:18 UTC, alex burton wrote:
>>>
>>> Hardware exceptions allow for the same thing.
>>
>> I am not sure what you mean by the above.
>
> You can trap the segfault and access a OS-specific data
> structure which tells you where it happened, then recover if
> the runtime supports it.
Thanks for this.
I tested the same code on Windows and it appears that you can
catch exceptions of unknown type using catch with no exception
variable. The stack is unwound properly and scope(exit) calls
work as expected etc.
After reading about signal handling in unix and structured
exception handling on Windows, it sounds possible though
difficult to implement a similar system on unix to introduce an
exception by trapping the seg fault signal, reading the data
structure you mention and then using assembler jump instructions
to jump into the exception mechanism.
So I take Walters statement to mean that :
hardware exceptions (AKA non software exceptions / SEH on
windows) fix the problem - where programmers have put catch
unknown exception statements after their normal catch statements
in the appropriate places.
And that a seg fault exception should result on linux it just
happens that it is not yet implmented, which is why we just get
the signal and crash.
More information about the Digitalmars-d
mailing list