Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone app crashes when launched from Xcode, but not from iPhone

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?

like image 935
Matt Connolly Avatar asked Dec 23 '22 01:12

Matt Connolly


1 Answers

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 :)

like image 182
Matt Connolly Avatar answered Jan 31 '23 06:01

Matt Connolly