iPhone crash weird need help

Hi

So I’ve tested my app on many devices and others have for me and so far no issues. Apple rejected the app though and sent two crash reports. The app is built with xcode 4.2 using base sdk 5.0 and min target iOS 4.3 using arm7 only. They seem to have tested it on iPad 2 (although its an iPhone app in the settings), but I guess it needs to run in x2 scaled up mode anyway.

Both reports show the crash as:

Hardware Model: iPad2,2
OS Version: iPhone OS 5.0.1 (9A405)

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x05385000
Crashed Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 Myapp 0x001c8fd0 ofPixels_::swapRgb() + 24
1 Myapp 0x001c5f02 void putBmpIntoPixels(FIBITMAP*, ofPixels_&, bool) + 266
2 Myapp 0x001c5256 ofLoadImage(ofPixels_&, std::string) + 678
3 Myapp 0x001c59d0 ofImage_::loadImage(std::string) + 96
4 Myapp 0x000066a4 screenMenu::loadAssets() + 280
5 Myapp 0x0000626e screenMenu::init(testApp*) + 1794
6 Myapp 0x000039da testApp::setup() + 198
7 Myapp 0x001ad3ca -[ofxiPhoneAppDelegate applicationDidFinishLaunching:] + 934
8 UIKit 0x3269c83e -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1270

So screenMenu class in the loadAssets() function simply does image.loadImage() a few times. It seems to be crashing at swapRgb() as the last called function in ofPixels?

If anyone has any ideas I’d greatly appreciate it. Also any tips on how I can better debug this too?

Thanks

I’ve had similar swapRGB problems loading images at that specific resolution (1024x768) - not sure if it helps, but here’s a link to the issue. May help with debugging? https://github.com/openframeworks/openFrameworks/issues/802

Thanks, that could be the problem, looking into it. Its weird that it never happens to me or any testers, but it did to Apple. I was probably loading a 640x960 image at the time which might match the dimensions/aspect others were having issues with.

Just a heads up that this issue is fixed with the develop branch of OF – I haven’t seen it on iphone / iOS, but it was evident on lion / OSX for certain sized images.

I noticed this crash on osx and in another project on iOS too. It only seems to happen in release-mode, debug has no problems. The solution in this-thread is apparently applied in the develop branch, but you could put it there yourself in your current version.

arturo’s code has worked for me which I believe reflects what is in the developer branch of ofPixel.cpp

  
  
// replace  
//		while (cnt < sizePixels){  
//			std::swap(pixels_ptr[0],pixels_ptr[2]);  
//			cnt++;  
//			pixels_ptr+=channels;  
//		}  
          
// new  
for(int i = 0; i < width*height; i++){      
  PixelType  tmp = pixels[i*channels];    
  pixels[i*channels] = pixels[i*channels+2];   
  pixels[i*channels+2] = tmp;    
}