iOS: Bad access is cxx_descruct - ios

I have a problem with an app crashing for a few users, I have no idea whats causing it and all I got is this stacktrace from crashlytics:
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x0000000194e5016c objc_release + 12
1 learnchinese 0x00000001000a95a0 -[WGRLanguageLabel .cxx_destruct] (WGRLanguageLabel.m:34)
2 libobjc.A.dylib 0x0000000194e36b1c object_cxxDestructFromClass(objc_object*, objc_class*) + 148
3 libobjc.A.dylib 0x0000000194e43f38 objc_destructInstance + 92
4 libobjc.A.dylib 0x0000000194e43f90 object_dispose + 28
5 UIKit 0x0000000187f8771c -[UIResponder dealloc] + 116
6 UIKit 0x0000000187c3dc38 -[UIView dealloc] + 1000
7 learnchinese 0x00000001000a5460 -[WGRLanguageLabel dealloc] (WGRLanguageLabel.m:39)
8 CoreFoundation 0x00000001830a10f8 CFRelease + 524
9 CoreFoundation 0x00000001830ad6b8 -[__NSArrayM dealloc] + 152
10 libobjc.A.dylib 0x0000000194e51724 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 564
11 CoreFoundation 0x00000001830a4d14 _CFAutoreleasePoolPop + 28
12 UIKit 0x0000000187c34584 _wrapRunLoopWithAutoreleasePoolHandler + 76
13 CoreFoundation 0x000000018317bff0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
14 CoreFoundation 0x0000000183178f7c __CFRunLoopDoObservers + 360
15 CoreFoundation 0x000000018317935c __CFRunLoopRun + 836
16 CoreFoundation 0x00000001830a4f74 CFRunLoopRunSpecific + 396
17 GraphicsServices 0x000000018cb076fc GSEventRunModal + 168
18 UIKit 0x0000000187ca6d94 UIApplicationMain + 1488
19 learnchinese 0x00000001001679ec main (main.m:13)
20 libdyld.dylib 0x00000001954e2a08 start + 4
It looks like WGRLanguageLabel has been released when auto release pool try to release it again.
Here is the dealloc method in WGRLanguageLabel:
#implementation WGRLanguageLabel
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
...
#end

Related

when __NSDictionaryM dealloc crash

For a crash in my application, NSDictionary is an attribute of the model, and when the model executes the cxx_destruct function, crash occurs inside the NSDictionary.There's a place in the crash stack that I'm not sure about cow_cleanup, what's going on in this function?
And The reason for the crash is that during the model release process, NSDictionary changed, right?
Here is the concrete Crash stack
Thread 0 Crashed:
0 libobjc.A.dylib objc_release + 16
1 CoreFoundation cow_cleanup + 168
2 CoreFoundation -[__NSDictionaryM dealloc] + 144
3 imeituan -[CKContent .cxx_destruct] (CKContent.m:12)
4 libobjc.A.dylib object_cxxDestructFromClass(objc_object*, objc_class*) + 112
5 libobjc.A.dylib objc_destructInstance + 88
6 libobjc.A.dylib _objc_rootDealloc + 52
7 imeituan -[CKTableViewCell .cxx_destruct] (CKTableViewCell.m:44)
8 libobjc.A.dylib object_cxxDestructFromClass(objc_object*, objc_class*) + 112
9 libobjc.A.dylib objc_destructInstance + 88
10 libobjc.A.dylib _objc_rootDealloc + 52
11 UIKitCore -[UIResponder dealloc] + 152
12 UIKitCore -[UIView dealloc] + 872
13 UIKitCore -[UITableViewCell dealloc] + 236
14 imeituan -[CKBubbleCell dealloc (CKBubbleCell.m:222)
15 CoreFoundation -[__NSArrayM dealloc] + 228
16 UIKitCore -[UITableView .cxx_destruct] + 1524
17 libobjc.A.dylib object_cxxDestructFromClass(objc_object*, objc_class*) + 112
18 libobjc.A.dylib objc_destructInstance + 88
19 libobjc.A.dylib _objc_rootDealloc + 52
20 UIKitCore -[UIResponder dealloc] + 152
21 UIKitCore -[UIView dealloc] + 872
22 UIKitCore -[UIScrollView dealloc] + 852
23 UIKitCore -[UITableView dealloc] + 364
24 UIKitCore __destroy_helper_block_e8_32s40s + 24
25 libsystem_blocks.dylib _Block_release + 148
26 Foundation -[_NSTimerBlockTarget dealloc] + 44
27 Foundation _timerRelease + 64
28 CoreFoundation __CFRunLoopDoTimer + 936
29 CoreFoundation __CFRunLoopDoTimers + 276
30 CoreFoundation __CFRunLoopRun + 1640
31 CoreFoundation CFRunLoopRunSpecific + 424
32 GraphicsServices GSEventRunModal + 160
33 UIKitCore UIApplicationMain + 1932
34 imeituan main (main.m:38)
35 libdyld.dylib start + 4
Crashes like this are really tricky. The key to keep in mind is that you are crashing during a deallocation. And, more specifically, the crashing function is objc_release. To me, this strongly indicates that you've got an over-released object. It's looks to me like one of your model objects may have already been freed by this point. The issue isn't with the dictionary, directly.
I'd recommend using NSZombies, or one of the other memory allocation tools within Instruments to try to track down where your memory-management issue is.

KVO observer crash on iOS 11

I’ve a app in App Store which was working fine on iOS 10. But recently I’m getting many crash reports and all logs points to KVO crash and all are happening on iOS 11, below is the crash log.
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x181e7a858 object_isClass + 16
1 Foundation 0x1836d72bc KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 68
2 Foundation 0x1836d5ad0 NSKeyValueWillChangeWithPerThreadPendingNotifications + 300
3 QuartzCore 0x186e35024 -[CALayer setDelegate:] + 108
4 UIKit 0x18c866698 -[UIView dealloc] + 708
5 UIKit 0x18c93f08c -[UILabel dealloc] + 192
6 libobjc.A.dylib 0x181e9a13c (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 844
7 UIKit 0x18c86678c -[UIView dealloc] + 952
8 CoreFoundation 0x182b911b4 -[__NSArrayM dealloc] + 140
9 libobjc.A.dylib 0x181e9a13c (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 844
10 UIKit 0x18c86678c -[UIView dealloc] + 952
11 libobjc.A.dylib 0x181e9a13c (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 844
12 UIKit 0x18c86678c -[UIView dealloc] + 952
13 libobjc.A.dylib 0x181e9a13c (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 844
14 UIKit 0x18c86678c -[UIView dealloc] + 952
15 UIKit 0x18cbd3248 -[UINavigationTransitionView dealloc] + 96
16 libobjc.A.dylib 0x181e9a13c (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 844
17 UIKit 0x18c86678c -[UIView dealloc] + 952
18 UIKit 0x18cbd319c -[UILayoutContainerView dealloc] + 60
19 libobjc.A.dylib 0x181e9a13c (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 844
20 CoreFoundation 0x182b88aac _CFAutoreleasePoolPop + 28
21 UIKit 0x18cc705fc _prepareForCAFlush + 132
22 UIKit 0x18cb555b8 _afterCACommitHandler + 236
23 CoreFoundation 0x182c6a910 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
24 CoreFoundation 0x182c68238 __CFRunLoopDoObservers + 412
25 CoreFoundation 0x182c68884 __CFRunLoopRun + 1436
26 CoreFoundation 0x182b88da8 CFRunLoopRunSpecific + 552
27 GraphicsServices 0x184b6b020 GSEventRunModal + 100
28 UIKit 0x18cb6978c UIApplicationMain + 236
29 MyApp 0x1009bf748 main (main.m:14)
30 libdyld.dylib 0x182619fc0 start + 4
The crashes has crossed over 200 crashes and all are same logs. I’ve not been able to reproduce this crash and kind of stuck on how to proceed next. My entire project is written in objective-C and when I checked there is only one method where I’m using a KVO. Below is a model of my method on how I’ve used it.
-(void)loadData
{
//Some code
if (myAlerts) {
[myAlerts removeObserver:self forKeyPath:#“liveAlerts"];
}
myAlerts = myModel.alerts;
[myAlerts addObserver:self forKeyPath:#"liveAlerts" options:NSKeyValueObservingOptionInitial context:NULL];
}
To remove I use the cleanup method in other viewcontrollers when I no longer need it
-(void)cleanup
{
//Some code
[myAlerts removeObserver:self forKeyPath:#"liveAlerts"];
myAlerts = nil;
}
All the other observers which I've added in my project are NSNotificationCenter observers, could that cause this type of crash log?

How to Resolve "RemoveObjectAtIndex"

I have an property:
#property (nonatomic, retain) QBChatDialog* dialog;
When i make it nil in viewWillDisappear, it giving me error
- (void)viewWillDisappear:(BOOL)animated {
self.dialog = nil;
}
I am getting following error:
-[__NSArrayM removeObjectAtIndex:]: index 2147483647 beyond bounds for empty array'
even i don't use "removeObjectAtIndex". I think this is calling somewhere internally.
How to trace this.
my Complete Stack trace is:
(
0 CoreFoundation 0x05504494 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x05cd6e02 objc_exception_throw + 50
2 CoreFoundation 0x0540b2cd -[__NSArrayM removeObjectAtIndex:] + 445
3 Qboy 0x0026d23e -[TWMessageBarViewController statusBarHidden] + 43262
4 Qboy 0x002acffc QBAFQueryStringPairsFromKeyAndValue + 110104
5 libobjc.A.dylib 0x05cea060 _ZN11objc_object17sidetable_releaseEb + 238
6 libobjc.A.dylib 0x05ce9361 objc_release + 65
7 libobjc.A.dylib 0x05ce9318 objc_storeStrong + 39
8 Qboy 0x0007a35a -[ChatVC .cxx_destruct] + 298
9 libobjc.A.dylib 0x05cd58e2 _ZL27object_cxxDestructFromClassP11objc_objectP10objc_class + 116
10 libobjc.A.dylib 0x05cd5869 object_cxxDestruct + 20
11 libobjc.A.dylib 0x05cdfcb6 objc_destructInstance + 48
12 CoreFoundation 0x0550e57c -[NSObject(NSObject) __dealloc_zombie] + 156
13 UIKit 0x038de904 -[UIResponder dealloc] + 162
14 UIKit 0x03855e85 -[UIViewController dealloc] + 2296
15 Qboy 0x0017bf93 -[QMChatViewController dealloc] + 835
16 UIKit 0x040c1b75 -[UIViewController(UIKitManual) release] + 88
17 libobjc.A.dylib 0x05ce934f objc_release + 47
18 libobjc.A.dylib 0x05cea52d _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 371
19 CoreFoundation 0x053d48a8 _CFAutoreleasePoolPop + 24
20 CoreFoundation 0x0540c43c __CFRunLoopRun + 2364
21 CoreFoundation 0x0540b846 CFRunLoopRunSpecific + 470
22 CoreFoundation 0x0540b65b CFRunLoopRunInMode + 123
23 GraphicsServices 0x06eef664 GSEventRunModal + 192
24 GraphicsServices 0x06eef4a1 GSEventRun + 104
25 UIKit 0x03688eb9 UIApplicationMain + 160
26 Qboy 0x000db84a main + 138
27 libdyld.dylib 0x062cca25 start + 1
28 ??? 0x00000001 0x0 + 1
)
Please suggest me. What to do?
error tells you that
you have an array which is empty/nil
and after that you are removing an item of object which object is no longer exists in this array
Trick: for quick fix search 'removeObjectAtIndex' all overs the project(from upper left 3rd search button). if find one/lot observe those
You may not be calling removeObjectAtIndex: inside viewWillDisappear:, but you are calling it within -[TWMessageBarViewController statusBarHidden]. Look there and I think you'll find the source of your crash!

SIGABRT ABORT in QuartzCore

I'm seeing crashlogs being generated containing the following call stack
Thread : Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x38a0a1f0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x38a74797 pthread_kill + 58
2 libsystem_c.dylib 0x389bafdd abort + 76
3 libsystem_malloc.dylib 0x38a32d67 free + 382
4 libobjc.A.dylib 0x3844e3ad object_dispose + 20
5 UIKit 0x305511ef -[UIViewAnimationState dealloc] + 174
6 libobjc.A.dylib 0x38456b6b objc_object::sidetable_release(bool) + 174
7 CoreFoundation 0x2dc2d93d CFRelease + 556
8 QuartzCore 0x30195635 CA::release_objects(X::List<void const*>*) + 16
9 QuartzCore 0x3019aad7 -[CAAnimation dealloc] + 54
10 libobjc.A.dylib 0x38456b6b objc_object::sidetable_release(bool) + 174
11 CoreFoundation 0x2dc2d93d CFRelease + 556
12 QuartzCore 0x3019d117 CA::Layer::run_animation_callbacks(void*) + 238
13 libdispatch.dylib 0x3892f81f _dispatch_client_callout + 22
14 libdispatch.dylib 0x3893649f _dispatch_main_queue_callback_4CF$VARIANT$mp + 278
15 CoreFoundation 0x2dcc78f1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
16 CoreFoundation 0x2dcc61c5 __CFRunLoopRun + 1300
17 CoreFoundation 0x2dc30f0f CFRunLoopRunSpecific + 522
18 CoreFoundation 0x2dc30cf3 CFRunLoopRunInMode + 106
19 GraphicsServices 0x32b52663 GSEventRunModal + 138
20 UIKit 0x3057c16d UIApplicationMain + 1136
21 Domino M 0x000c125f main (main.m:14)
Other threads only show the AFNetworking library doing something.
How can I find and fix issues like this (the ones that don't seem to have anything to do with self written code)?

Odd CF_forwarding_prep_0 crash - possible UITableView delegate issue?

I'm trying to analyze a log for what appears to be an intermittent crash.
Here's the stack trace for the thread that throws the exception:
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2ab5f49f __exceptionPreprocess + 126
1 libobjc.A.dylib 0x38315c8b objc_exception_throw + 38
2 CoreFoundation 0x2ab5f3e5 -[NSException initWithCoder:]
3 Foundation 0x2b862389 -[NSProxy doesNotRecognizeSelector:] + 68
4 CoreFoundation 0x2ab627d7 ___forwarding___ + 714
5 CoreFoundation 0x2aa94058 _CF_forwarding_prep_0 + 24
6 UIKit 0x292648cb -[UIScrollViewAccessibility _axCleanupDelegateClearer] + 98
7 UIKit 0x29264965 -[UIScrollViewAccessibility dealloc] + 60
8 UIKit 0x2e19c8b1 -[UITableView dealloc] + 1572
9 UIKit 0x2924dc91 -[UITableViewAccessibility dealloc] + 172
10 libobjc.A.dylib 0x38314da1 object_cxxDestructFromClass(objc_object*, objc_class*) + 116
11 libobjc.A.dylib 0x3831e5f7 objc_destructInstance + 34
12 libobjc.A.dylib 0x3831e61b object_dispose + 14
13 UIKit 0x2e3214d1 -[UIResponder dealloc] + 96
14 UIKit 0x2e18eb55 -[UIViewController dealloc] + 1760
15 CoreFoundation 0x2aa6600d CFRelease + 600
16 CoreFoundation 0x2aa7968f -[__NSArrayI dealloc] + 66
17 libobjc.A.dylib 0x3832fd5f objc_object::sidetable_release(bool) + 166
18 libobjc.A.dylib 0x383301a9 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 404
19 CoreFoundation 0x2aa71149 _CFAutoreleasePoolPop + 16
20 UIKit 0x2e01789f _wrapRunLoopWithAutoreleasePoolHandler + 42
21 CoreFoundation 0x2ab25d95 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
22 CoreFoundation 0x2ab23453 __CFRunLoopDoObservers + 278
23 CoreFoundation 0x2ab2385b __CFRunLoopRun + 914
24 CoreFoundation 0x2aa713c1 CFRunLoopRunSpecific + 476
25 CoreFoundation 0x2aa711d3 CFRunLoopRunInMode + 106
26 GraphicsServices 0x31e6f0a9 GSEventRunModal + 136
27 UIKit 0x2e080fa1 UIApplicationMain + 1440
28 MyApp 0x000938b1 main (main.mm:21)
29 libdyld.dylib 0x38895aaf start + 2
And here's the stack trace for the main thread:
Thread : Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x3895bdfc __pthread_kill + 8
1 libsystem_pthread.dylib 0x389d9d37 pthread_kill + 62
2 libsystem_c.dylib 0x388fb909 abort + 76
3 libc++abi.dylib 0x37c399c9 __cxa_bad_cast
4 libc++abi.dylib 0x37c53671 default_unexpected_handler()
5 libobjc.A.dylib 0x38315f25 _objc_terminate() + 192
6 libc++abi.dylib 0x37c50de3 std::__terminate(void (*)()) + 78
7 libc++abi.dylib 0x37c508af __cxa_rethrow + 102
8 libobjc.A.dylib 0x38315dd3 objc_exception_rethrow + 42
9 CoreFoundation 0x2aa7145d CFRunLoopRunSpecific + 632
10 CoreFoundation 0x2aa711d3 CFRunLoopRunInMode + 106
11 GraphicsServices 0x31e6f0a9 GSEventRunModal + 136
12 UIKit 0x2e080fa1 UIApplicationMain + 1440
13 MyApp 0x000938b1 main (main.mm:21)
Looking through the trace with the exception, I see a CF_forwarding_prep_0 message, which is followed by an [NSProxy doesNotRecognizeSelector] exception. Reading that, is it a safe assumption that the cause of the issue is that there's a pointer to a tableview delegate that isn't being set to nil? That's about the only discernible thing I see here.
Any help would be most appreciated. Thanks!

Resources