This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [darwin] unwind context question
- From: Andreas Tobler <toa at pop dot agri dot ch>
- To: Geoffrey Keating <geoffk at apple dot com>
- Cc: GCC <gcc at gcc dot gnu dot org>, Geoffrey Keating <gkeating at apple dot com>, Mike Stump <mrs at apple dot com>
- Date: Mon, 07 Jul 2003 22:16:42 +0200
- Subject: Re: [darwin] unwind context question
- References: <4F5359A2-B0AA-11D7-83ED-0050E4BAD278@apple.com>
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.
Below the disass.
I would expect context->ra at 0x9000fae0 and not at 0x9000fa9c.
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.
What do you need to see?
Thanks,
Andreas