Crash UIScrollView EXC_BAD_ACCESS - ios

I'm having trouble to diagnostic a crash with UIScrollView
UIKit
-[UIScrollView setContentOffset:]
Exception Type: EXC_BAD_ACCESS Code KERN_INVALID_ADDRESS at 0xe0000008
com.apple.main-thread Crashed
0 libobjc.A.dylib objc_msgSend + 15
1 UIKit -[UIScrollView setContentOffset:] + 618
2 UIKit -[UITableView setContentOffset:] + 330
3 UIKit -[UIScrollView(Static) _adjustContentOffsetIfNecessary] + 1474
4 UIKit -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 414
5 UIKit -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:] + 30
6 UIKit -[UIScrollView removeFromSuperview] + 30
7 ... UIKit -[UIView dealloc] + 296
8 UIKit -[UIView dealloc] + 296
9 libobjc.A.dylib (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 168
10 CoreFoundation _CFAutoreleasePoolPop + 16
11 CoreFoundation __CFRunLoopRun + 1296
12 CoreFoundation CFRunLoopRunSpecific + 356
13 CoreFoundation CFRunLoopRunInMode + 104
14 GraphicsServices GSEventRunModal + 74
15 UIKit UIApplicationMain + 1120
16 iTV Shows main.m line 12

I had the same problem. Setting the TableView and ScrollView delegates (or any other delegates that you might have) to nil in the dealloc method solved the problem.
- (void)dealloc {
self.tableView.delegate = nil;
self.tableView.dataSource = nil;
}

Its hard to give a concrete answer without seeing your code, but the iOS Debugging Magic technical note is always a great resource with tips for debugging crashes.
Technical Note TN2239: iOS Debugging Magic

Related

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?

weird SIGSEGV crash in iOS

About 10+ crash reported by crittercism.
Name: SIGSEGV
Reason: SEGV_MAPERR
Seems it is a UIScrollView/UITableView animating or scrolling issue.
How can I find the root cause?
Stack:
0
libobjc.A.dylib 0x0000000195fafbd0 objc_msgSend + 12
1
UIKit 0x00000001892b1db8 -[UIScrollView(UIScrollViewInternal) _delegateScrollViewAnimationEnded] + 64
2
UIKit 0x00000001892b1d30 -[UIScrollView(UIScrollViewInternal) _scrollViewAnimationEnded:finished:] + 204
3
UIKit 0x0000000189366814 -[UIAnimator stopAnimation:] + 500
4
UIKit 0x0000000189366248 -[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 332
5
QuartzCore 0x0000000188b4629c CA::Display::DisplayLinkItem::dispatch() + 28
6
QuartzCore 0x0000000188b46134 CA::Display::DisplayLink::dispatch_items() + 320
7
IOKit 0x0000000185921470 IODispatchCalloutFromCFMessage + 372
8
CoreFoundation 0x0000000184712dc4 __CFMachPortPerform + 176
9
CoreFoundation 0x0000000184727a54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
10
CoreFoundation 0x00000001847279b4 __CFRunLoopDoSource1 + 432
11
CoreFoundation 0x0000000184725934 __CFRunLoopRun + 1636
12
CoreFoundation 0x00000001846512d4 CFRunLoopRunSpecific + 392
13
GraphicsServices 0x000000018de676fc GSEventRunModal + 164
14
UIKit 0x0000000189216fac UIApplicationMain + 1484
15
MyApp 0x000000010001d280 main (main.m:14)
16
libdyld.dylib 0x000000019661aa08 start + 0
I've seen this happen when a controller and/or its table is deallocated during an animation. The OS still triggers delegate methods (e.g., -scrollViewDidEndScrollingAnimation: or -scrollViewDidEndDecelerating:) when it finishes with the animation, but because the objects no longer exist things get weird.
The best fix is to nil the delegate in the controller's dealloc method.

I get some layout constraints error in iOS

I get some error log info,But the position is not the position code, can you help me to point out the cause of the problem
Below is the details of the crash log, I can't find more position the code, what's the problem.
detail crash log:
The layout constraints still need update after sending -updateConstraints to <_UIKeyboardLayoutAlignmentView: 0x13e6ea660; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <CALayer: 0x17443ffe0>>.
_UIKeyboardLayoutAlignmentView or one of its superclasses may have overridden -updateConstraints without calling super. Or, something may have dirtied layout constraints in the middle of updating them. Both are programming errors.
(null)
(
0 CoreFoundation 0x0000000185d602f4 <redacted> + 160
1 libobjc.A.dylib 0x000000019758c0e4 objc_exception_throw + 60
2 CoreFoundation 0x0000000185d60218 <redacted> + 0
3 UIKit 0x000000018ae64748 <redacted> + 448
4 UIKit 0x000000018ae64880 <redacted> + 136
5 CoreFoundation 0x0000000185c40cdc CFArrayApplyFunction + 68
6 UIKit 0x000000018ae64620 <redacted> + 152
7 UIKit 0x000000018ae64880 <redacted> + 136
8 CoreFoundation 0x0000000185c40cdc CFArrayApplyFunction + 68
9 UIKit 0x000000018ae64620 <redacted> + 152
10 UIKit 0x000000018ae64880 <redacted> + 136
11 UIKit 0x000000018a89b7b4 <redacted> + 104
12 Foundation 0x0000000186bc1308 <redacted> + 176
13 UIKit 0x000000018a89b4d0 <redacted> + 212
14 UIKit 0x000000018a8b7e04 <redacted> + 104
15 UIKit 0x000000018ae64be4 <redacted> + 180
16 UIKit 0x000000018a7b2140 <redacted> + 588
17 UIKit 0x000000018ac71bd0 <redacted> + 792
18 UIKit 0x000000018aaa8fb0 <redacted> + 1860
19 UIKit 0x000000018a824240 <redacted> + 356
20 UIKit 0x000000018a7946ec <redacted> + 536
21 CoreFoundation 0x0000000185d182a4 <redacted> + 32
22 CoreFoundation 0x0000000185d15230 <redacted> + 360
23 CoreFoundation 0x0000000185d15610 <redacted> + 836
24 CoreFoundation 0x0000000185c412d4 CFRunLoopRunSpecific + 396
25 GraphicsServices 0x000000018f4576fc GSEventRunModal + 168
26 UIKit 0x000000018a806fac UIApplicationMain + 1488
27 Myapp 0x1001803b0 Myapp + 1573808
28 libdyld.dylib 0x0000000197c0aa08 <redacted> + 4
)
dSYM UUID: B1FB72DD-A4D0-3ABA-BF95-9FCD83749770
CPU Type: arm64
Slide Address: 0x0000000100000000
Binary Image: Myapp
Base Address: 0x00000001000f0000
If you implemented updateConstraints you need to call [super updateConstraints]; within your implementation.
See https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/occ/instm/UIView/updateConstraints
UPDATE:
_UIKeyboardLayoutAlignmentView is an Apple internal keyboard view. Most likely something is crashing while it is presented.
See this Radar (Apple bug report) and these answers for a potential solution.
The bug seems to be iOS 8.3 specific.
https://openradar.appspot.com/20615507
NSInteralInconsistencyException - UIKeyboardLayoutAlignmentView
iOS 8.3 UIAlertController crashes when trying to add a textfield

App Crashes when NavigationController is popped

App crashing when pop two times the navigationController and in iPhone log return this error :(
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x6545f661
Triggered by Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x3a081636 objc_msgSend + 22
1 UIKit 0x322bef20 -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 60
2 UIKit 0x32039188 -[UIScrollView setContentOffset:] + 592
3 UIKit 0x320e61e6 -[UITableView setContentOffset:] + 346
4 UIKit 0x322bfe62 -[UIScrollView(UIScrollViewInternal) _adjustContentOffsetIfNecessary] + 1350
5 UIKit 0x320ebd0e -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 410
6 UIKit 0x320ebb66 -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:] + 26
7 UIKit 0x320ebb22 -[UIScrollView removeFromSuperview] + 26
8 UIKit 0x3201a3b6 -[UIView dealloc] + 374
9 libobjc.A.dylib 0x3a0870d2 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 354
10 CoreFoundation 0x2f730c14 _CFAutoreleasePoolPop + 12
11 CoreFoundation 0x2f7c6176 __CFRunLoopRun + 1302
12 CoreFoundation 0x2f730eba CFRunLoopRunSpecific + 518
13 CoreFoundation 0x2f730c9e CFRunLoopRunInMode + 102
14 GraphicsServices 0x3468a65e GSEventRunModal + 134
15 UIKit 0x3207d148 UIApplicationMain + 1132
16 Big24H 0x000e9728 main (main.m:16)
17 libdyld.dylib 0x3a584ab4 start + 0
Looks like you have a UIScrollViewDelegate being deallocated before its corresponding UIScrollView and then getting called.
You didn't provide any code so the best I can say is you need to find where it is and nil it out when it is getting deallocated.
Probably something like this:
- (void) dealloc
{
myScrollView.delegate = nil;
}

ios crash issue - EXC_BAD_ACCESS

I got this error message from Crashlytics.
Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0xd000000c
Thread 0: Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x3b283b26 objc_msgSend + 5
1 TestApp 0x0012b239 -[EasyTableView scrollViewDidScroll:] (EasyTableView.m:291)
2 UIKit 0x339f006d -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 64
3 UIKit 0x3376d375 -[UIScrollView setContentOffset:] + 596
4 UIKit 0x3381b005 -[UITableView setContentOffset:] + 320
5 UIKit 0x3376d0e7 -[UIScrollView _adjustContentOffsetIfNecessary] + 1354
6 UIKit 0x33820773 -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 414
7 UIKit 0x338205cb -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:] + 30
8 UIKit 0x33820587 -[UIScrollView removeFromSuperview] + 30
9 UIKit 0x3374e687 -[UIView dealloc] + 366
10 liboainject.dylib 0x002d86cd ___swapMethods_block_invoke_4
11 UIKit 0x3374e687 -[UIView dealloc] + 366
12 liboainject.dylib 0x002d86cd ___swapMethods_block_invoke_4
13 UIKit 0x3374e687 -[UIView dealloc] + 366
14 liboainject.dylib 0x002d86cd ___swapMethods_block_invoke_4
15 libobjc.A.dylib 0x3b285007 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 358
16 liboainject.dylib 0x002d7d33 __oa__objc_autoreleasePoolPop
17 CoreFoundation 0x30f10a41 _CFAutoreleasePoolPop + 16
18 UIKit 0x337464cd _wrapRunLoopWithAutoreleasePoolHandler + 36
19 CoreFoundation 0x30fa81d5 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
20 CoreFoundation 0x30fa5b79 __CFRunLoopDoObservers + 284
21 CoreFoundation 0x30fa5ebb __CFRunLoopRun + 730
22 CoreFoundation 0x30f10ce7 CFRunLoopRunSpecific + 522
23 CoreFoundation 0x30f10acb CFRunLoopRunInMode + 106
24 GraphicsServices 0x35bfa283 GSEventRunModal + 138
25 UIKit 0x337b2a41 UIApplicationMain + 1136
26 TestApp 0x000ea19d main (main.m:16)
My code (EasyTableView.m: 291) is as below
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if ([delegate respondsToSelector:#selector(easyTableView:scrolledToOffset:)])
[delegate easyTableView:self scrolledToOffset:self.contentOffset];
}
- (CGPoint)contentOffset {
CGPoint offset = self.tableView.contentOffset;
if (_orientation == EasyTableViewOrientationHorizontal)
offset = CGPointMake(offset.y, offset.x);
return offset;
}
- (void)setContentOffset:(CGPoint)offset {
if (_orientation == EasyTableViewOrientationHorizontal)
self.tableView.contentOffset = CGPointMake(offset.y, offset.x);
else
self.tableView.contentOffset = offset;
}
I tried to debug with Zombie and looked into Leaks of instrument. But I could not found any thing. How can I fix this problem? Thanks in advance
You should clear the scrollView and tableView delegates in dealloc
In Swift :
deinit {
self.scrollView.delegate = nil
self.tableView.delegate = nil
}

Resources