Re: how to disable floating point exceptions?
Re: how to disable floating point exceptions?
- Subject: Re: how to disable floating point exceptions?
- From: "Kyle Sluder" <email@hidden>
- Date: Wed, 15 Aug 2007 18:27:33 -0400
EXC_ARITMETIC is a Mach exception, not a signal. Your process is
dying before the signal handler is called. The 387 is historically
more inflexible about floating-point exceptions than PowerPC anyway.
A quick Google search brought this up:
http://lists.apple.com/archives/Darwin-dev/2007/May/msg00044.html
...which referenced this:
http://developer.apple.com/documentation/Performance/Conceptual/Mac_OSX_Numerics/Mac_OSX_Numerics.pdf
Don't forget, this is the Xcode mailing list. You might have better
luck if you posted this to the correct mailing list.
--Kyle Sluder
On 8/15/07, alex <email@hidden> wrote:
> Wouldn't it be easier to just adjust your math or simply check for zero before dividing rather than fiddling with the processor??
>
> a
>
> At 9:47 AM +1200 8/16/07, Rua Haszard Morris wrote:
> >Is it possible to prevent an application crashing on EXC_ARITHMETIC (e.g. divide by zero) on i386?
> >
> >I believe that on PPC there is no crash, and no crash when running in rosetta (this is somewhat beside the point however).
> >
> >I have tried installing a signal handler using sigaction, and calling sigaction specifying SIG_IGN to hopefully ignore the exception (see code snippet below).
> >
> >The signal handler approach mostly worked, in that my signal handler was called, but the crash behaviour remained, in that I wasn't able to call an emergency exit function from within the signal handler; the app didn't disappear, but wasn't responsive, and either the call to emergency quit wasn't effective or didn't happen. Also the "App has unexpectedly quit" crash handler kicked in as per normal.
> >
> >SIG_IGN didn't seem to have any effect different than normal exception behaviour (it must mean that only the _app_ ignores the signal).
> >
> >Does anyone know how to intercept floating point exceptions when running on i386 such that the program flow can be resumed enough to inform the user and quit the app a little more gracefully?
> >
> >Is my problem that I don't know how to (or can't) circumvent crashreporter handling the exception?
> >
> >any hints would be greatly appreciated
> >Rua HM.
> >
> >// example code. acknowledgements to http://gcc.gnu.org/ml/gcc-help/2002-04/msg00003.html
> >
> >void fpeHandler (int, siginfo_t*, void*)
> >{
> > FAIL( "Floating-point exception" ); // essentially an assert(false), string appears in console successfully
> > CleanUpAndExit(false); // quit-now-but-please-don't-crash function, is called, but app doesn't quit nicely
> >}
> >
> >void initFpe()
> >{
> > struct sigaction sa;
> > sa.sa_flags = SA_SIGINFO;
> > sa.sa_sigaction = fpeHandler; // this results in my callback (sig handler) being called, but crashreporter still takes over
> >
> > sigaction (SIGFPE, &sa, 0);
> >}
> >
> >main()
> >{
> >....
> > initFpe();
> > // run app etc
> > // perform complex sequence of actions leading to divide-by-zero ...
> >...
> >}
> >_______________________________________________
> >Do not post admin requests to the list. They will be ignored.
> >Xcode-users mailing list (email@hidden)
> >Help/Unsubscribe/Update your Subscription:
> >
> >This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden