I'm checking self.next_id is not null why would this line crash? I can't reproduce the issue on my test devices. I only get crash reports from Crashlytics at this line.
-(Second*)getNextSecond:(BOOL)returnSelf{
Second* retValue = nil;
if(self.next_id){
//this line !!!!
retValue = [[SecondDatabase sharedManager] getSecond:[self.next_id stringValue]];
}
if (retValue == nil && returnSelf) {
return self;
}else{
return retValue;
}
}
This is my SecondDatabase sharedManager function:
#property NSMutableDictionary* dictionary;
- (id)init {
if (self = [super init]) {
_dictionary = [#{} mutableCopy];
}
return self;
}
+ (id)sharedManager {
static SecondDatabase *sharedMyManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedMyManager = [[self alloc] init];
});
return sharedMyManager;
}
This is my getSecond function:
-(Second*)getSecond:(NSString*)idString{
return [_dictionary objectForKey:idString];
}
Where should I be investigating? Would this crash if dictionary didn't have object for key so that it returns NULL?
My crash report:
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x000007d8
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x3acd164c realizeClass(objc_class*) + 19
1 libobjc.A.dylib 0x3acd1715 realizeClass(objc_class*) + 220
2 libobjc.A.dylib 0x3acd1715 realizeClass(objc_class*) + 220
3 libobjc.A.dylib 0x3acd39ab lookUpImpOrForward + 74
4 libobjc.A.dylib 0x3acd3957 _class_lookupMethodAndLoadCache3 + 34
5 libobjc.A.dylib 0x3acd88b9 _objc_msgSend_uncached + 24
6 itsmysecond-ios 0x001287c7 -[Second getNextSecond:] (Second.m:93)
7 itsmysecond-ios 0x000fd5ff -[EBParallaxViewController adjustViewsToSeconds] (EBParallaxViewController.m:181)
8 itsmysecond-ios 0x000fd21d -[EBParallaxViewController scrollViewDidEndDecelerating:] (EBParallaxViewController.m:154)
9 UIKit 0x32ed6957 -[UIScrollView(UIScrollViewInternal) _stopScrollDecelerationNotify:] + 806
10 UIKit 0x32e0cd47 -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 466
11 UIKit 0x32e0cb6b -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:] + 30
12 UIKit 0x32ed621b -[UIScrollView _smoothScrollWithUpdateTime:] + 3322
13 QuartzCore 0x32a06df3 CA::Display::DisplayLinkItem::dispatch() + 98
14 QuartzCore 0x32a06b9d CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 344
15 IOMobileFramebuffer 0x3577f75d IOMobileFramebufferVsyncNotifyFunc + 104
16 IOKit 0x31209451 IODispatchCalloutFromCFMessage + 248
17 CoreFoundation 0x304ddea9 __CFMachPortPerform + 136
18 CoreFoundation 0x304e8a67 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
19 CoreFoundation 0x304e8a03 __CFRunLoopDoSource1 + 346
20 CoreFoundation 0x304e71d7 __CFRunLoopRun + 1398
21 CoreFoundation 0x30451ebf CFRunLoopRunSpecific + 522
22 CoreFoundation 0x30451ca3 CFRunLoopRunInMode + 106
23 GraphicsServices 0x35357663 GSEventRunModal + 138
24 UIKit 0x32d9e14d UIApplicationMain + 1136
25 itsmysecond-ios 0x00109707 main (main.m:14)
26 libdyld.dylib 0x3b1dbab7 start + 2
Related
I am experiencing a random crash in the following method:
- (void) addLineToVCard:(NSMutableString **)vCard forKey:(NSString *)key setValue:(NSString *)value
{
[*vCard appendString:[NSString stringWithFormat:#"%#:%#\r\n", key, value]];
}
and I'm calling this as:
NSMutableString* vCard = [NSMutableString string];
[self addLineToVCard:&vCard forKey:#"BEGIN" setValue:#"VCARD"];
[self addLineToVCard:&vCard forKey:#"VERSION" setValue:#"3.0"];
What am I doing wrong ? I could avoid this by passing a reference instead of a pointer object. But I would like to know the reason of crash here.
The crash log:
Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x251e6c5c __pthread_kill + 8
1 libsystem_pthread.dylib 0x25290733 pthread_kill + 62
2 libsystem_c.dylib 0x2517b0ad abort + 108
3 libsystem_malloc.dylib 0x252180ad free_list_checksum_botch + 362
4 libsystem_malloc.dylib 0x252181db free_tiny_botch + 66
5 CoreFoundation 0x255332d3 __CFStringChangeSizeMultiple + 1838
6 CoreFoundation 0x2553178b __CFStringCheckAndReplace + 554
7 CoreFoundation 0x25491557 -[__NSCFString appendString:] + 26
8 iPhoneHandheldACT 0x1ae7cf -[ContactDetailViewController addLineToVCard:forKey:setValue:] (ContactDetailViewController.m:3009)
9 iPhoneHandheldACT 0x1ae515 -[ContactDetailViewController assembleVCard:] (ContactDetailViewController.m:2987)
10 iPhoneHandheldACT 0x1adcbd -[ContactDetailViewController shareVCard:] (ContactDetailViewController.m:2927)
11 iPhoneHandheldACT 0x1ad351 __47-[ContactDetailViewController btnSharePressed:]_block_invoke (ContactDetailViewController.m:2813)
12 UIKit 0x29f2cbd9 -[UIAlertController _fireOffActionOnTargetIfValidForAction:] + 68
13 UIKit 0x29f2d283 __85-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:]_block_invoke + 30
14 UIKit 0x29e237e3 -[UIPresentationController transitionDidFinish:] + 1230
15 UIKit 0x29e26a85 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 192
16 UIKit 0x29c04157 -[_UIViewControllerTransitionContext completeTransition:] + 90
17 UIKit 0x29b11ba5 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 540
18 UIKit 0x29b11685 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 204
19 UIKit 0x29b1157f -[UIViewAnimationState animationDidStop:finished:] + 78
20 QuartzCore 0x27b71689 CA::Layer::run_animation_callbacks(void*) + 252
21 libdispatch.dylib 0x250c980f _dispatch_client_callout + 22
22 libdispatch.dylib 0x250d7ba9 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1524
23 CoreFoundation 0x2551db6d __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
24 CoreFoundation 0x2551c067 __CFRunLoopRun + 1574
25 CoreFoundation 0x2546b229 CFRunLoopRunSpecific + 520
26 CoreFoundation 0x2546b015 CFRunLoopRunInMode + 108
27 GraphicsServices 0x26a5bac9 GSEventRunModal + 160
28 UIKit 0x29b3f189 UIApplicationMain + 144
29 iPhoneHandheldACT 0xcbe21 main (main.m:16)
30 libdispatch.dylib 0x25113873 (Missing)
The pointer's pointer is not necessary, just like this:
- (void)addLineToVCard:(NSMutableString *)vCard forKey:(NSString *)key setValue:(NSString *)value
{
[vCard appendFormat:#"%#:%#\r\n", key, value];
}
Then use it:
NSMutableString* vCard = [NSMutableString string];
[self addLineToVCard:vCard forKey:#"BEGIN" setValue:#"VCARD"];
[self addLineToVCard:vCard forKey:#"VERSION" setValue:#"3.0"];
The result:
(lldb) po vCard
BEGIN:VCARD
VERSION:3.0
My ios app running ok on all the devices. It shows crash On iphone 6plus original device only.
Not getting exact issue. On Crashlytics we get issue report online, with this error. Below is a error log.
Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x1864c3014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x18658b450 pthread_kill + 112
2 libsystem_c.dylib 0x186437400 abort + 140
3 libsystem_c.dylib 0x18640b3b8 __assert_rtn + 220
4 Metal 0x189b1c3a4 MTLReportFailure + 780
5 Metal 0x189af9c48 -[MTLTextureDescriptorInternal validateWithDevice:] + 568
6 AGXMetalA8 0x1a13efe14 (Missing)
7 QuartzCore 0x18a830104 allocate_drawable_private(unsigned int, unsigned int, id<MTLDevice>, MTLPixelFormat, MTLTextureRotation, bool, bool, bool, unsigned int, CGColorSpace*, _CAImageQueue*) + 320
8 QuartzCore 0x18a82fcf8 -[CAMetalLayer nextDrawable] + 1492
9 VectorKit 0x19358fbc0 -[MetalLayer _updateDrawable] + 68
10 VectorKit 0x19358fc64 -[MetalLayer onTimerFired:] + 56
11 VectorKit 0x193221834 -[VKMapView onTimerFired:] + 176
12 VectorKit 0x193582dbc -[GGLDisplayLink _displayLinkFired:] + 84
13 QuartzCore 0x18a74af24 CA::Display::DisplayLinkItem::dispatch(unsigned long long) + 44
14 QuartzCore 0x18a74add0 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 444
15 IOKit 0x187762094 IODispatchCalloutFromCFMessage + 372
16 CoreFoundation 0x18748ae50 __CFMachPortPerform + 180
17 CoreFoundation 0x1874a3218 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
18 CoreFoundation 0x1874a29cc __CFRunLoopDoSource1 + 436
19 CoreFoundation 0x1874a04b0 __CFRunLoopRun + 1840
20 CoreFoundation 0x1873ce2b8 CFRunLoopRunSpecific + 444
21 GraphicsServices 0x188e82198 GSEventRunModal + 180
22 UIKit 0x18d4157fc -[UIApplication _run] + 684
23 UIKit 0x18d410534 UIApplicationMain + 208
24 SafeSide 0x1000d7998 main (main.m:14)
25 libdispatch.dylib 0x1863b15b8 (Missing)
Edit:
Did select row's code:
#try
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
MonitorVC *monitor = Init_VCforStoryId(#"MonitorVC");
monitor.monitorPassed = [arrMonitorList objectAtIndex:indexPath.row];
[self.navigationController pushViewController:monitor animated:YES];
}
#catch (NSException *exception)
{
NSLog(#"Exception handle: %#",exception.reason);
}
Usually app works great, but i received issue in Crashlytics. It's happen 1-2 times in week. For 2k-3k users. App work on iOS 7 and later.
Report: Fatal Exception: NSInvalidArgumentException
-[UIPasteboard setString:]: Argument is not an object of type NSString [(null)]
Here stack of thread where app crashed:
Thread : Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x38fae1f0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x390167b7 pthread_kill + 58
2 libsystem_c.dylib 0x38f5eff9 abort + 76
3 libc++abi.dylib 0x383ad98f abort_message + 74
4 libc++abi.dylib 0x383c66e7 default_terminate_handler() + 254
5 libobjc.A.dylib 0x389f9f7d _objc_terminate() + 192
6 APPNAME 0x001f1495 CPPExceptionTerminate() (KSCrashSentry_CPPException.mm:193)
7 libc++abi.dylib 0x383c41b3 std::__terminate(void (*)()) + 78
8 libc++abi.dylib 0x383c3a09 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
9 libobjc.A.dylib 0x389f9dbb objc_exception_throw + 250
10 CoreFoundation 0x2e25ee0d -[NSException initWithCoder:]
11 UIKit 0x30e3e0eb -[UIPasteboard(UIPasteboardDataExtensions) setString:] + 154
12 APPNAME 0x0011cfaf __33-[WebViewController moreActions:]_block_invoke_2 (WebViewController.m:424)
13 UIKit 0x30c74ceb __56-[UIActivityViewController _cleanupActivityWithSuccess:]_block_invoke + 54
14 UIKit 0x30ba87c9 -[UIWindowController transitionViewDidComplete:fromView:toView:removeFromView:] + 1880
15 UIKit 0x30ba7f9f __101-[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:]_block_invoke293 + 170
16 UIKit 0x30ba7ecb -[_UIViewControllerTransitionContext completeTransition:] + 74
17 UIKit 0x30ba7db1 -[UITransitionView notifyDidCompleteTransition:] + 288
18 UIKit 0x30ba78c1 -[UITransitionView _didCompleteTransition:] + 944
19 UIKit 0x30ac83b7 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 178
20 UIKit 0x30ac82cf -[UIViewAnimationState animationDidStop:finished:] + 66
21 QuartzCore 0x30712e0b CA::Layer::run_animation_callbacks(void*) + 234
22 libdispatch.dylib 0x38ee2d3f _dispatch_client_callout + 22
23 libdispatch.dylib 0x38ee56c3 _dispatch_main_queue_callback_4CF + 278
24 CoreFoundation 0x2e229641 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
25 CoreFoundation 0x2e227f0d __CFRunLoopRun + 1308
26 CoreFoundation 0x2e192729 CFRunLoopRunSpecific + 524
27 CoreFoundation 0x2e19250b CFRunLoopRunInMode + 106
28 GraphicsServices 0x331016d3 GSEventRunModal + 138
29 UIKit 0x30af3871 UIApplicationMain + 1136
30 APPNAME 0x000b9287 main (main.m:16)
App crahed in WebViewController in function moreActions.
12 APPNAME 0x0011cfaf __33-[WebViewController moreActions:]_block_invoke_2 (WebViewController.m:424)
This Function show UIActivityViewController and one of custom action - copy link to web page.
__weak WebViewController *weakSelf = self;
[activityViewController setCompletionHandler:^(NSString *activityType, BOOL completed) {
WebViewController *strongSelf = weakSelf;
if ([activityType isEqualToString:#"VK"]) {
// actions
} else if ([activityType isEqualToString:#"copyLink"]) {
// HERE UIPasteboard!
UIPasteboard *pb = [UIPasteboard generalPasteboard];
[pb setString:[strongSelf.startUrl absoluteString]];
}
}];
Make sure that [strongSelf.startUrl absoluteString] does not returns nil just before setting it to pasteboard string. I'm pretty sure that your startUrl apparently becomes nil.
I am getting this crash showing up in BugSense:
-[NSConcreteData count]: unrecognized selector sent to instance 0x14e57f10 - NSInvalidArgumentException
in this code:
+ (NSMutableArray *)applyFilters:(NSMutableArray *)theItems fromFilter:(NSDictionary *)filters
{
NSMutableArray *items = [[NSMutableArray alloc] initWithArray:theItems];
if ([[filters allKeys] count] > 0)
{
NSMutableArray *tempFilteredItems = [[NSMutableArray alloc] init];
for (NSString *key in [filters allKeys])
{
NSMutableString *convertedKey = [NSMutableString stringWithString:key];
[convertedKey replaceOccurrencesOfString:#" "
withString:#"_"
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [convertedKey length])];
NSArray *tempFilterAttributes = [NSArray arrayWithArray:filters[key]];
for (NSDictionary *item in items)
{
if (![[item[convertedKey] componentsSeparatedByString:#"*"] firstObjectCommonWithArray:tempFilterAttributes])
{
if (![tempFilteredItems containsObject:item])
{
[tempFilteredItems addObject:item];
}
}
}
[items removeObjectsInArray:tempFilteredItems];
[tempFilteredItems removeAllObjects];
}
}
return items;
}
Why/how is this happening?
Stack trace is:
CoreFoundation <redacted> + 130
1 libobjc.A.dylib objc_exception_throw + 38
2 CoreFoundation <redacted> + 202
3 CoreFoundation <redacted> + 706
4 CoreFoundation _CF_forwarding_prep_0 + 24
5 CoreFoundation <redacted> + 28
6 Video Games +[Helper applyFilters:fromFilter:] (Helper.m:2862)
7 Video Games -[WishlistViewController loadUp] (WishlistViewController.m:409) + 29303
8 Video Games -[WishlistViewController viewWillAppear:] (WishlistViewController.m:363) + 27955
9 UIKit <redacted> + 374
10 UIKit <redacted> + 612
11 UIKit <redacted> + 572
12 UIKit <redacted> + 44
13 UIKit <redacted> + 184
14 UIKit <redacted> + 380
15 QuartzCore <redacted> + 142
16 QuartzCore <redacted> + 350
17 QuartzCore <redacted> + 16
18 QuartzCore <redacted> + 228
19 QuartzCore <redacted> + 314
20 UIKit <redacted> + 126
21 CoreFoundation <redacted> + 20
22 CoreFoundation <redacted> + 286
23 CoreFoundation <redacted> + 738
24 CoreFoundation CFRunLoopRunSpecific + 524
25 CoreFoundation CFRunLoopRunInMode + 106
26 GraphicsServices GSEventRunModal + 138
27 UIKit UIApplicationMain + 1136
28 Video Games main (main.m:16) + 888911
29 libdyld.dylib <redacted> + 2
The problem has nothing to do with the code that you provided. The error messages says that the message count was sent to the class NSConcreteData, which is essentially the same as NSData, and such a class method does not exist.
I suggest that you set an exception breakpoint (in Xcode select left the breakpoint navigator, click + left bottom, and select add exception breakpoint).
When you execute the app, it will stop at the faulty instruction.
EDIT (due to the stack trace you provided now):
The stack trace indeed says that your method applyFilters:fromFilter: is responsible for the crash. The only place where the message count is sent in this method, is the statement [[filters allKeys] count]. It looks then that count is sent to an NSConcreteData object, and not to an NSArray object as you might have expected. One reason could be that the argument filters, that should be a NSDictionary, is an object of a different type.
So when the app stops at the exception breakpoint, please check the class of the instance filters.
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
}