[Bf-committers] floating point exception calls needed for osx/windows (--debug-fpe)

Campbell Barton ideasman42 at gmail.com
Mon May 24 06:52:57 CEST 2010


The argument --debug-fpe to enable floating point exceptions currently
only works on linux & SGI.

This command is useful for tracking down invalid floating point math,
divide by zero, invalid arguments to math.h functions & operations
resulting in NAN or INF, since you get a crash at the point in the
code where the error is made.

For example, it made finding this bug simple ([#22398 black pixels
with HDR textures).
http://markmail.org/message/vlkta3nzwmm3sywr

This is the function in creator.c now. just needs mac/windows #ifdefs,
probably not hard but needs testing by a developer who uses osx/win.

---

static int set_fpe(int argc, char **argv, void *data)
{
#if defined(__sgi) || defined(__linux__)
	/* zealous but makes float issues a heck of a lot easier to find!
	 * set breakpoints on fpe_handler */
	signal(SIGFPE, fpe_handler);

#if defined(__linux__) && defined(__GNUC__)
	feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
#endif
#endif
	return 0;
}

-- 
- Campbell


More information about the Bf-committers mailing list