Question

So I'm having a bit of a difficult time troubleshooting a crash log that I'm getting from our tester. The app is crashing with a EXC_CRASH (SIGSEGV), and the only recognizable code in any of the threads is in thread 6. The stack trace looks like this:

...
15  MyApplication                   0x002cfcf2 0xfb000 + 1920242
16  MyApplication                   0x00107f26 -[CCViewController dealloc] (CCViewController.m:73)
17  MyApplication                   0x001cc27c -[CCSubmitReportController dealloc] (CCSubmitReportController.m:646)
18  CoreFoundation                  0x36f41c3c 0x36f3f000 + 11324
...
26  Foundation                      0x35396bd4 0x35387000 + 64468
27  MyApplication                   0x001c794e -[CCGetFeedOperation main] (CCGetFeedOperation.m:102)
...

If you look at line 102 in CCGetFeedOperation, it's just draining the operation's autorelease pool at the end of its work.

So I'm trying to figure out why the autorelease pool would be trying to release the delegate. The reference to the delegate is passed to the operation class as such:

@property (assign) id <CCGetFeedOperationDelegate> feedDelegate;

The only thing I can think of is that I'm invoking a method on the main thread and waiting for it to complete before calling the pool drain.

invocation = [NSInvocation invocationWithTarget:feedDelegate
                                                       selector:@selector(operation:didGetFeed:) 
                                            retainArguments:YES, self, feedDetailsModel];

But that still doesn't necessarily explain why the operation's pool would be causing the view controller to be deallocated. Thoughts?

edit: btw, I have not been able to reproduce this. I've only seen it in crash reports from our testers and from people in the wild.

edit 2: the autorelease pool is quite simple, it's allocated at the beginning of the operation's main method, and drained when the work is done.

Was it helpful?

Solution

If you crash during draining the autorelease pool, that just means you over-released something somewhere during that event loop. If that same object has an autorelease on it, then you won't see the crash until the pool drains. It doesn't mean that autorelease has anything to do with it. That's just when the last release happened.

Make sure that you are using accessors for all your property access (except in init and dealloc). Direct access to ivars is the #1 cause if this kind if crash in non-ARC code. In any case, you'll need to audit your balancing of retain and release. Moving to ARC will generally reduce these kinds if errors and is highly recommended if possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top