Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone app crashes only in Release mode on 3G

I have an app I'm writing that crashes when I call addSubview on a UIScrollView with "EXC_BAD_ACCESS". It only does this on iPhone 3G in release mode and only on the device. I works fine in all these other configurations:

iPhone 3G - Debug mode iPhone 3GS - Debug AND Release Mode iPhone 4 - Debug AND Release Mode Simulator - all.

Furthermore, there is no rational reason why this should be happening. My object is not released by any of my code.

like image 402
whitehawk Avatar asked Nov 10 '10 23:11

whitehawk


3 Answers

I had the exact same problem recently, however I am not entirely sure the cause is the same. What I can tell you though is what resolved the issue for me (although I'm still not entirely satisfied with the solution).

In the end, it seems like a compiler issue, and this might confirm what others have said about compiler optimization. I am using Xcode 4.0 (build 4A304a). The issue was with LLVM compiler 2.0 Code Generation. One key in particular: "Optimization Level"

Debug was set to "None". Release was set to "Fastest, Smallest"

Changing Release to "None" fixed the crash (and similarly changing Debug to "Fastest, Smallest" caused the app the crash on launch).

like image 126
aSadhankar Avatar answered Nov 14 '22 01:11

aSadhankar


I recommend you to use NSZombieEnabled to find out what is causing a bad access to memory.

  • Do you use DEBUG / RELEASE defines to branch your code?
  • Do you use SDK version checkers to branch your code?

Otherwise I can't see how your app can behave diferently on different devices/configurations.

like image 2
Juan Fran Jimenez Avatar answered Nov 14 '22 03:11

Juan Fran Jimenez


I can propose to change optimization level of release settings to "None". I met the same problem few times (with different apps) and solved it in this way.

like image 1
brigadir Avatar answered Nov 14 '22 02:11

brigadir