In my iphone project I always insert UITableView into the view controller as IBOutlet, most times it works well, but random crash will occur when do animation invoked by popToRootViewControllerAnimated. Track it by zombie, find the crash dues to UITableView instance has been deallocated, but there are still system events sent to it, so crash.
I always resolve such issue by either of the following methods in view controller's dealloc method.
tableView.dataSource = nil; (work for most cases)
or
[tableView removeFromSuperview]; (work for some special cases)
Although the crash can be fixed by the above change, but I am still confusing.
- Is it apple's defect that we need to set its dataSource to nil explicitly to avoid crash? Or maybe our own app code has problem?
- Anyone who has also experienced such crash, do you know what's the root cause?
Any idea or discussion will be appreciated, thanks in advance.
enter code here
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x626f6d37
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x33fe0c98 objc_msgSend + 16
1 UIKit 0x364538f6 -[UITableView(UITableViewInternal) _spacingForExtraSeparators] + 58
2 UIKit 0x3645337a -[UITableView(_UITableViewPrivate) _adjustExtraSeparators] + 158
3 UIKit 0x36453218 -[UITableView layoutSubviews] + 40
4 UIKit 0x363ff5f4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 20
5 CoreFoundation 0x30e13efc -[NSObject(NSObject) performSelector:withObject:] + 16
6 QuartzCore 0x33d8dbae -[CALayer layoutSublayers] + 114
7 QuartzCore 0x33d8d966 CALayerLayoutIfNeeded + 178
8 QuartzCore 0x33d931be CA::Context::commit_transaction(CA::Transaction*) + 206
9 QuartzCore 0x33d92fd0 CA::Transaction::commit() + 184
10 QuartzCore 0x33d8c04e CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 50
11 CoreFoundation 0x30e7da2e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 10
12 CoreFoundation 0x30e7f45e __CFRunLoopDoObservers + 406
13 CoreFoundation 0x30e80754 __CFRunLoopRun + 848
14 CoreFoundation 0x30e10ebc CFRunLoopRunSpecific + 224
15 CoreFoundation 0x30e10dc4 CFRunLoopRunInMode + 52
16 GraphicsServices 0x34efe418 GSEventRunModal + 108
17 GraphicsServices 0x34efe4c4 GSEventRun + 56
18 UIKit 0x36428d62 -[UIApplication _run] + 398
19 UIKit 0x36426800 UIApplicationMain + 664
20 ScoutFree 0x00099558 0x1000 + 623960
21 ScoutFree 0x00003618 0x1000 + 9752