|
From: | Richard Frith-Macdonald |
Subject: | Re: Exception Handling and _NS_COUNT_HACK |
Date: | Mon, 27 Oct 2008 20:14:07 +0000 |
On 27 Oct 2008, at 19:02, Samantha Rahn wrote:
I am finding that Objective-C exceptions are not being caught when my GNUstep-built DLL is run as an in-memory COM server within a protected memory space, such as (a) Excel and (b) GDB. I have tracked the problem down to signal handlers not being called. Could this be the reason that exceptions are not being handled?For example, consider the following program that generates a SIGSEGV crash.-- #include <signal.h> #include <stdio.h> void recover(int); int main(int argc, const char *argv[]) { signal(SIGSEGV, recover); int *intPtr = 0; printf("Crash %d", *intPtr); return 0; } void recover(int signal) { int value = signal; printf("Signal generated: %d\n", value); } -- When running from the command line, the signal handler function, recover(), is called as expected:ToolSignal generated: 11However, the problem shows up when the program is run within GDB: the signal handler is not called. Any ideas about this and its possible ramification for proper exception handling when running the DLL as an in-process COM server?
A couple of points ...1. when running under gdb, gdb catches any signal ... so you then have to continue the program specially, telling gdb to pass the signal back to the program. If you just continue the program normally from the gdb command line then the signal is never delivered to the program(since it was delivered to gdb).
2. the signal handler hack is a workaround for a bug in the gcc compiler's stack frame handling ... I've only ever seen the stack frame bug on 64bit systems and as far as I know the compiler will correctly detect the end of the stack if you are running on a 32bit system, in which case no signal is raised when handling an exception anyway. In other words, the signal handler should probably *not* be being called anyway.
So ... most likely if the exception handling is not working properly for you, the fault lies elsewhere.
[Prev in Thread] | Current Thread | [Next in Thread] |