How to detect where NaN is passing to CoreGraphics API on Mac OS X 10.9

Igor picture Igor · Oct 4, 2013 · Viewed 7.7k times · Source

I have very large graphic Mac app and now I receive a lot of the following messages in Console on 10.9 GM.

<Error>: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API. This is a serious error and contributes to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

I noticed that these messages appear in debugger after calling [NSApp nextEventMatchingMask: untilDate inMode: dequeue] but I think the reasons are in some other places. But I have too many places where I use Cocoa Graphics. I didn't receive this kind of message before 10.9.

How to detect where NaN is passing to CoreGraphics API?

Screenshot for this error on console

Answer

Tom Dalling picture Tom Dalling · Nov 8, 2013

After much digging around, I've found you can set a symbolic breakpoint on "CGPostError" in Xcode, and that will give you a stack trace.