Turning a SIGSEGV into a regular function call under Linux, allowing throw

deadalnix deadalnix at gmail.com
Wed Mar 14 12:52:55 PDT 2012


Le 14/03/2012 18:01, Vladimir Panteleev a écrit :
> On Wednesday, 14 March 2012 at 16:39:29 UTC, deadalnix wrote:
>> Le 14/03/2012 17:34, Vladimir Panteleev a écrit :
>>> On Wednesday, 14 March 2012 at 07:35:50 UTC, FeepingCreature wrote:
>>>> Sweet. Yeah, I think you need to use naked and reconstruct the
>>>> stackframe. Not sure how it'd look; I'm not familiar with the x86_64
>>>> ABI.
>>>
>>> I think it might be safe to just reconstruct the stack frame in the
>>> signal handler, and set gregs[REG_EIP] to &_d_throw directly. It should
>>> also use a pre-allocated exception object (like how it's done with
>>> OutofMemoryError and InvalidMemoryOperationError), in case there's data
>>> corruption in the GC.
>>
>> Especially if the signal is sent because of stack overflow !
>
> Not sure if sarcasm..?
>
> In case of a stack overflow, you can't call _d_throwc (or use the
> "throw" statement) anyway.

You can page protect the last segment of the stack, and unprotect it 
before throwing.


More information about the Digitalmars-d mailing list