2

I have a weird problem that hopefully someone could shed some light on.

I have an ipad app in the AppStore that was released when 3.2 was the only available iOS for ipad. App ran fine on this iOS but as soon as 4.2.1 came out for ipad and some of my users therefore updated to the new iOS the app now crashes when a certain UIBarButtonItem is pressed. In the interim from iOS 3.2 to when iOS 4.2.1 came out i submitted no updates so it was the exact same app running on each iOS yet i had this problem only on 4.2

After symbolicating in Organizer and viewing the Distribution build crash report I am able to at least see the line of code that is causing this...

while(i < [filteredData count]) {

thats it!!...just a simple check during a while loop. The last thing in the crash log points to the above line of code....

filteredData is a NSMutableArray that is definitely allocated/initialized at this point. It is actually used in another piece of code before this with no problems. Again, this line of code gave my app no problems on iOS 3.2 but on iOS 4.2.1 it causes EXC_BAD_ACCESS (SIGSEGV)

When i install the app on my device via xcode with a debug or release config it works perfect but when installing from AppStore (distribution build) it crashes and only on 4.2!

Just to clarify.....

app works perfect on debug AND distribution modes on 3.2

app works perfect on debug mode on 4.2 BUT app crashes on distribution mode on 4.2

Any thoughts? .....cuz i'm confused/lost Thanks for taking the time

KingofBliss
  • 15,055
  • 6
  • 50
  • 72
freddyD
  • 25
  • 1
  • 6
  • When you go into the build tap of your Target's info, what differences are there between the distribution and debug configurations? (The way to tell if there's a difference in any field is to select "All Configurations", then scroll down and look for "Multiple Values" or a dash across a check mark.) – Sam Ritchie Dec 08 '10 at 04:03
  • theres the expected path differences (debug-iphoneos vs. distribution-iphoneos). "Validate built product" is checked on distribution not on debug. The setting "strip debug symbols during copy" is checked on distribution but not on debug. "Optimization level" is "none" on debug, "fastest, smallest" on distribution. Other C flags and C++ flags both are blank on debug but on distribution they are "-DNS_BLOCK_ASSERTIONS=1" – freddyD Dec 09 '10 at 03:16

1 Answers1

3

Possibly an optimisation made by the compiler in Release builds causes this, especially as you dont get the issue in Debug

Can you refactor to...

NSUInteger count = [filteredData count];
while(i < count) {

Or is filteredData mutating in the loop?

NSUInteger count = [filteredData count];
while(i < count) {
   blah;
   blah;
   count = [filteredData count];
}
Warren Burton
  • 17,451
  • 3
  • 53
  • 73
  • yeah, refactoring is not a problem at all here. The problem is how do i check if that helped or not?? As mentioned it only happens on Distribution build so how can i check? As you may know the approval process in AppStore is not the fastest so it would take weeks and weeks to narrow this down....not to mention annoying my users because they'll keep getting updates with no fix – freddyD Dec 09 '10 at 03:02
  • Nope just rebuild as Release mode but sign with your dev cert. See this. http://stackoverflow.com/questions/4288964/cant-deploy-a-release-version-with-developer-profile It will prove if the optimisation level is to blame. You want to change "Optimization Level" to "fastest+smallest" in your target settings – Warren Burton Dec 09 '10 at 08:31
  • hmm..yeah it seems it is an optimisation issue. Changing the level does show the crash which is great cause now i can actually see it happening and fix it. Weird thing is the line/lines of code causing the crash are within the while loop...even if the loop isn't entered! At least i can see it now...thanks!! – freddyD Dec 12 '10 at 00:02
  • its weird....when i build in release mode the opto level is already set to fastest+smallest and it DIDN'T crash. When i build in debug mode and just simply change the opto level to fastes+smallest (from none) it DOES crash. I think i fixed my problem but just curious... isn't a distribution build a clone of a release build? Yet it crashes on distribution, doesn't crash on release and does crash on debug with opto level jacked up! I just don't see a pattern there. Anyway, thanks for the help! – freddyD Dec 12 '10 at 05:21