This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Geoffrey Keating wrote:
Won't Darwin do this for you? All you should need to do is catch SIGSEGV.
Well, not from my experience. I tried, but not success. Maybe I run a kernel which is to old? But I don't think so.
#include <stdio.h> int main(int argc, char *argv[]) { printf("%d",*((int*)0)); return 0; }
[titanium:~/gcc-work/exception] andreast% ./print Bus error
I write to a protected mem area.
[titanium:~/gcc-work/exception] andreast% gdb print Program received signal EXC_BAD_ACCESS, Could not access memory. 0x00001db0 in main () (gdb)
So, these kind of errors end up in KERN_PROTECTION_FAILURE. And a SIGSEGV does not help. At least I didn't manage it to catch the failure.
It would be much easier to handle a SEGV than incorporate a mach msg handler.
Maybe. It's hard to tell without seeing how the return address got set. You'll note that the code there does eventually wind up in sigreturn.Below the disass. I would expect context->ra at 0x9000fae0 and not at 0x9000fa9c.
What do you need to see?
-- Geoff Keating <geoffk@apple.com>
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |