www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - trying setjmp or throwing from signal handler crashes on OSX

reply "timotheecour" <thelastmammoth gmail.com> writes:
Is there any way to get setjmp to work in a D program on OSX?
I just get a segfault whenever it is called.

I'm just trying to recover from a signal handler.

Related questions:
why is signal handler nothrow?

I saw this related thread but it seems linux only:
http://www.deadalnix.me/2012/03/24/get-an-exception-from-a-segfault-on-linux-x86-and-x86_64-using-some-black-magic/
with code:
http://www.deadalnix.me/wp-content/uploads/2012/03/sigsegv.d.txt
Sep 01 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-09-02 02:37, timotheecour wrote:
 Is there any way to get setjmp to work in a D program on OSX?
 I just get a segfault whenever it is called.

 I'm just trying to recover from a signal handler.

 Related questions:
 why is signal handler nothrow?

 I saw this related thread but it seems linux only:
 http://www.deadalnix.me/2012/03/24/get-an-exception-from-a-segfault-on-linux-x86-and-x86_64-using-some-black-magic/

 with code:
 http://www.deadalnix.me/wp-content/uploads/2012/03/sigsegv.d.txt
Since this is kind of low level I would guess you cannot just take a Linux guide and have it work on Mac OS X. Both are Posix but at this low level the differences between the platforms start to show up. BTW, I get "Error: undefined identifier ucontext_t" when compiling that file on Mac OS X. -- /Jacob Carlborg
Sep 02 2012
parent reply "timotheecour" <thelastmammoth gmail.com> writes:
 Since this is kind of low level I would guess you cannot just 
 take a Linux guide and have it work on Mac OS X. Both are Posix 
 but at this low level the differences between the platforms 
 start to show up.

 BTW, I get "Error: undefined identifier ucontext_t" when 
 compiling that file on Mac OS X.
I got that too. So I also tried linking my D program against a C library that would call those set jmp and long jmp functions, but that crashed too. So I guess there's currently no clean way to recover from signals on OSX ?
Sep 02 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-09-03 00:05, timotheecour wrote:

 I got that too. So I also tried linking my D program against a C library
 that would call those set jmp and long jmp functions, but that crashed
 too. So I guess there's currently no clean way to recover from signals
 on OSX ?
I have no idea. -- /Jacob Carlborg
Sep 02 2012