views:

53

answers:

2

I have an app that is crashing on the iPhone, but only when it launched via Xcode.

I can see in the iPhone console log that the app receives a memory warning, and then there are some strange events like these:

Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Bug: launchd_core_logic.c:3270 (24132):0
Sun Jul 11 00:03:43 Matts-iPhone com.apple.debugserver-48[5590] <Warning>: 1 [15d6/1403]: error: ::read ( 6, 0x3809f4, 1024 ) => -1 err = Bad file descriptor (0x00000009)
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Bug: launchd_core_logic.c:2688 (24132):10
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Working around 5020256. Assuming the job crashed.
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Warning>: (UIKitApplication:com.mycom.myapp[0x3f60]) Job appears to have crashed: Segmentation fault
Sun Jul 11 00:03:43 Matts-iPhone SpringBoard[40] <Warning>: Application 'Phone' exited abnormally with signal 9: Killed
Sun Jul 11 00:03:45 Matts-iPhone SpringBoard[40] <Warning>: Application 'myapp' exited abnormally with signal 11: Segmentation fault

However, when I launch the app from the phone (not via Xcode) then it works as expected. (There is a memory warning during launch. I know it's running tight, but it recovers and doesn't crash).

This is making it particularly hard to debug other issues.

Have I stumbled across some iOS bug?

Any ideas?

A: 

Usually, when you see a crash on simulator but not device or vice versa it indicates a fault with a library that is compiled for one hardware but not the other.

However, if your memory is tight, then you're probably seeing a crash caused by the subtle differences between code compiled for Intel versus code compiled for ARM. The Intel code is likely just more sensitive for some reason. The same problem will eventually occur on device if you leave it running long enough under tight memory.

TechZen
A: 

Turns out in my case that I'd forgotten that I still had the "NSZombiesEnabled" environment variable set, which was increasing the real memory usage (causing the crash) when launched from Xcode. When launched directly from Springboard, that environment variable wasn't set, and the app used lots less memory.

It's very useful for debugging... until you run out of memory and forget it's there :)

TheSoundOfMatt