• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CrashReporter, signals and exception ports
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CrashReporter, signals and exception ports


  • Subject: Re: CrashReporter, signals and exception ports
  • From: Steve Checkoway <email@hidden>
  • Date: Fri, 6 Jan 2006 13:31:10 -0800

On Jan 6, 2006, at 1:15 PM, Jean-Francois Im wrote:
This all started when I noticed that an application's windows are not closed until the CrashReporter's close button is clicked. It makes sense for most applications to show a dialog instead of just magically vanishing and leaving a dialog box behind, however, when the application is a fullscreen window, the CrashReporter actually appears "behind" the application, with the side effect that the close button cannot be clicked.

This causes no end of frustration, doesn't it? *sigh*


Simple enough, I thought, it's just a matter of adding a signal handler, catch the signal for the exceptions, close the window, then resend the signal to ourself, thus causing the CrashReporter to pop up. Unfortunately, CrashReporter sets up an exception port, thus intervening before the signal handler has a chance to do something(because the exception is not translated into a signal).

We do this just with a signal handler. We catch:

static int signals[] =
{
    SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGABRT,
    SIGQUIT, SIGSEGV, SIGTRAP, SIGTERM, SIGVTALRM, SIGXCPU, SIGXFSZ,
#if defined(HAVE_DECL_SIGPWR) && HAVE_DECL_SIGPWR
    SIGPWR,
#endif
    -1
};

And then we set up the signal handlers using:

        struct sigaction sa;

        sa.sa_flags = 0;
        if( p != NULL )
            sa.sa_flags |= SA_ONSTACK;
        sa.sa_flags |= SA_NODEFER;
        sa.sa_flags |= SA_SIGINFO;
        sigemptyset(&sa.sa_mask);

        /* Set up our signal handlers. */
        sa.sa_sigaction = SigHandler;
        for( int i = 0; signals[i] != -1; ++i )
            sigaction( signals[i], &sa, NULL );

where p is the pointer to our signal stack set up with sigaltstack. Doing this we can shut down the full screen graphics context and perform any other clean up. We actually give a stack trace (among other things) ourself and setting the handlers seems to prevent the Crash Reporter from running.

Thus, I've searched for information on how to set up an exception port and have it rethrow the exception after closing the window, but documentation is quite scarce on the topic of exception ports. I have found a couple of pointers which sent me on the right track, but now I appear to have hit a wall.

We didn't have to do anything with exception ports to get this to work.

- Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >CrashReporter, signals and exception ports (From: Jean-Francois Im <email@hidden>)

  • Prev by Date: CrashReporter, signals and exception ports
  • Next by Date: xcodebuild question
  • Previous by thread: CrashReporter, signals and exception ports
  • Next by thread: Re: CrashReporter, signals and exception ports
  • Index(es):
    • Date
    • Thread