Sometimes my iPhone application crashes with a weird crashlog, that reads exception code is 0x8badf00d. The stacktraces show random snapshots of app execution, but nothing suspicious. This happens very rarely and I'm not able to find out how to reproduce it. Does anybody know more about this kind of exception and exception code?
Here is an excerpt from my crashlogs:
Exception Type: 00000020
Exception Codes: 0x8badf00d
Highlighted Thread: 0Application Specific Information:
Failed to deactivateThread 0:
...
< nothing suspicious here >
...Unknown thread crashed with unknown flavor: 5, state_count: 1
0x8badf00d
is the error code that the watchdog raises when an application takes too long to launch or terminate. See Apple's Crash Reporting for iPhone OS Applications documentfrom wikipedia 0xBAADF00D ("bad food") is used by Microsoft's LocalAlloc(LMEM_FIXED) to indicate uninitialised allocated heap memory when the debug heap is used.[7]
It's some programmer's idea of a joke. You have to pick a number for your code, but the number doesn't necessarily mean anything in itself.
8badf00d
is just another way to write the number 2,343,432,205, and was chosen because it looks 'funny' when represented in hex for an exception log.0x8badf00d exception
is raised by apple provided watchdog. The most common cause for watchdog timeout crashes in a network application is synchronous networking on the main thread. There are four contributing factors here:There are two common solutions:
Refer apple docs for more information.
It is HexSpeak, see here: http://en.wikipedia.org/wiki/Hexspeak
It's a failure code added by a dev with a good sense of humor. Because hexadecimal uses letters as well as numbers, it's possible to come up with hex numbers that look approximately like english words, such as "0xdeadbeef", etc. I'm sure that the exception has a specific meaning, but if there's no major symptoms associated with it, you can probably ignore it without too much concern.