Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

app runs fine with debug build, but crash on release build, what could be the possible reasons?

I have Xcode 4.3.1, iOS 5.1, and have ARC turned on for building my app.

Now the app runs fine in debug build, but crash on release build. What could be the possible reason for the difference? I purely rely on ARC for the resource management. I looked at the crash log, it's indicating that the memory that was referencing was released already. What'll be the common pitfalls that could cause the problem on retail build, when using ARC?

The following is what I got from crash log

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

EDIT

The app's deployment target is iOS 5.0. I do use internet connections, the current crash happens on the time when "rendering" the data returned from web service in order to show on a UITableViewController. The whole app is using ARC, except a few source files from 3rd party for which I have ARC turned off.

like image 612
tom Avatar asked Apr 01 '12 07:04

tom


1 Answers

Whenever this happens to me it seems to be because release builds are more aggressive about clearing up weak references. If you mistakenly assign something to a weak property (for example, if you're adding subviews that you will also hold weak references to) before you have any strong reference to it, this can work on debug and fail on release. For example (pseudocode)

@property (weak) UILabel * label;
...
self.label = [[UILabel alloc] init]; 
[self.view addSubview:self.label];
...
self.label.text = @"hello";

I've seen this cause bad access crashes on release builds and go unnoticed on debug.

like image 163
jrturton Avatar answered Oct 14 '22 07:10

jrturton