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]

Re: [darwin] unwind context question


Geoffrey Keating wrote:

[titanium:~/gcc-work/exception] andreast% ./print
Bus error


That's some kind of bug, I've noticed it with GCC. The signal that is thrown really is SIGSEGV, but either (a) it gets named 'Bus error' or (b) it gets passed to the handler as SIGBUS. If you try to catch SIGSEGV, you will get that error.

Hm, in my darwin-signal.h I do:


# define INIT_SEGV
  do
    {
      struct sigaction sa;
      darwin_init_mach_exceptions();
      sa.sa_flags = SA_SIGINFO;
      sa.sa_sigaction = catch_segv;
      sigemptyset (&sa.sa_mask);
      sigaction(SIGBUS, &sa, NULL);
      sigaction(SIGSEGV, &sa, NULL);

    }
 while (0)

And from the xnu sources I see:
xnu/bsd/uxkern/ux_exception.c

* ux_exception translates a mach exception, code and subcode to
* a signal and u.u_code.  Calls machine_exception (machine dependent)
* to attempt translation first.

    if (machine_exception(exception, code, subcode, ux_signal, ux_code))
        return;

switch(exception) {

        case EXC_BAD_ACCESS:
                if (code == KERN_INVALID_ADDRESS)
                        *ux_signal = SIGSEGV;
                else
                        *ux_signal = SIGBUS;
                break;

So, this is from the xnu6.6 sources and I run a 6.3 from mrs. Could be that there is a bug?

Well, I tried a lot to avoid the mach msg handler. But then it was the only success to get into the exception and handle it.



(In any case, you could always just catch SIGBUS as well.) ^
----|

What do you need to see?


The instructions just before the ones you listed would be interesting. You could check this much more easily by just writing a signal handler that does return and seeing where it returns to...

Ok, I try further and I hopefully can provide you with the instructions later.


Thanks,

Andreas




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]