D - Unsafe and doomed

Adam D. Ruppe destructionator at gmail.com
Tue Jan 7 07:40:48 PST 2014


On Tuesday, 7 January 2014 at 12:51:51 UTC, alex burton wrote:
> 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.

If you are on linux and add this file to your project:
dmd2/src/druntime/import/etc/linux/memoryerror.d

(it is part of the regular dmd zip)

you might have to import it and call registerMemoryErrorHandler() 
but then it will do the magic tricks to turn a segfault into a D 
exception.

But this is a bit unreliable so it isn't in any default build.


More information about the Digitalmars-d mailing list