0

I am really banging my head on a strange issue. Some users of my app reported that the app does not start, but crashes after showing the startup screen 2 sec. This occurs only on older iPod 2G/iPhone 3G. After getting hands on a device were this occurs I tried to track it down.

The crash does not occur with debug code, but only with a release build. Not much of my code is executed at all until the crash occurs. Some UIViewControllers are initialized in my AppDelegate, and whatever sequence I choose here, the first of them fails after running through initWithNibName, which is the same for all controllers and handles the loading of the correct XIB for a universal app:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    NSString *ipadXib = [NSString stringWithFormat:@"%@-iPad", [[self class] description]];
    return [super initWithNibName:ipadXib bundle:nibBundleOrNil];
  } else {
    return [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  }
}

This code runs through well, but when returning from here, I end up with a SIGBUS error somewhere in UIKit (not my code). I suspect the above coding, because when I simply don't override initWithNibName (which is ok for the iPhone version), the complete code runs through. If I just call [super ...] here it also works, however I suspect the compiler to simply optimize it away then, having the same effect as not overriding it at all. Since the InterfaceIdiom is not iPad, only the identical super-function is used w/o changed parameters, so it should be a no-brainer. It works on all other devices else. No Analyzer errors, no leaks whatsover. It really happens so early that almost nothing of my code except the above was called at all when the crash occurs. And it happens to whatever controller I put first in the sequence of 4 controllers.

Any ideas? I am completely stuck...

habitoti
  • 209
  • 1
  • 15

2 Answers2

0

Just wondering what iOS they are running? UIUserInterfaceIdiomPad is available in iOS 3.2 and later.

If that's the case you should check this thread How does one get UI_USER_INTERFACE_IDIOM() to work with iPhone OS SDK < 3.2

Community
  • 1
  • 1
Radim
  • 1,505
  • 10
  • 18
0

After some more research (throughout the night :-( ), I found that it is simply a compiler issue with XCode 4.0 LLVM. Release notes for XCode 4.0.2 reveal, that specifically this compiler bug (hampering stack frames on arm6 architectures) is now fixed. After installing 4.0.2 and recompiling, everything works fine now. Strange enough that I get mails from Apple that I should buy an iPad 2 as a gift for Easter, or that a white iPhone is now available, but no information whatsoever that such an important fix was made about 2 weeks ago is being sent to developers :-(

habitoti
  • 209
  • 1
  • 15