un-catched segfault exception

Hxal hxal at freenode.d.channel
Fri Jan 11 08:36:17 PST 2008


> BCS Wrote:
> 
> > I uses this approach and it works just fine. (DMD/Linux and IIRC DMD/Win)
> 
> My bad, I must have remembered wrong, it does indeed work fine
> with dmd/linux; there aren't even any calls to abort in deh2.d

Actually, I remembered what is the problem with throwing exceptions
out of signal handlers with dmd/linux.
Such exceptions leak through immediate try-catch blocks.
This example would print out "caught in segfault1".

void segfault1 ()
{
	try
	{
		segfault2();
	}
	catch
	{
		writefln ("caught in sefgault1");
	}
}

void segfault2 ()
{
	try
	{
		int* a = cast(int*) 0xdeadc0de;
		*a = 1;
	}
	catch
	{
		writefln ("caught in sefgault2");
	}
}




More information about the Digitalmars-d mailing list