SIGSEGV:零星的崩溃问题 [英] SIGSEGV : Sporadic crash issue

查看:242
本文介绍了SIGSEGV:零星的崩溃问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试解决iOS应用中的崩溃问题。在此处共享一些崩溃日志。

Here is my first attempt to solve crash issue in iOS app. Sharing some crash logs here.

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x97ad6beb8
Crashed Thread:  11

Application Specific Information:
objc_msgSend() selector name: length

是我的第11个线程。

Thread 11 Crashed:
0   libobjc.A.dylib                      0x0000000180558150 objc_msgSend + 16
1   Foundation                           0x00000001824f3f60 -[NSString compare:] + 28
2   Foundation                           0x00000001824d88e0 _NSCompareObject + 60
3   CoreFoundation                       0x0000000181a99bd0 __CFSimpleMergeSort + 88
4   CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
5   CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
6   CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
7   CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
8   CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
9   CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
10  CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
11  CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
12  CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
13  CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
14  CoreFoundation                       0x0000000181a99c60 __CFSimpleMergeSort + 232
15  CoreFoundation                       0x00000001819c585c CFSortIndexes + 460
16  CoreFoundation                       0x00000001819c6f9c CFMergeSortArray + 372
17  Foundation                           0x00000001824d80e8 _sortedObjectsUsingDescriptors + 568
18  Foundation                           0x00000001825c64e0 -[NSSet(NSKeyValueSorting) sortedArrayUsingDescriptors:] + 536
19  Eikon                                0x0000000100198b98 __51-[EIKNewsHeadlineStoreManager saveHeadlines:block:]_block_invoke (EIKNewsHeadlineStoreManager.m:67)
20  CoreData                             0x0000000183e5e214 developerSubmittedBlockToNSManagedObjectContextPerform + 148
21  libdispatch.dylib                    0x000000018099a9a0 _dispatch_client_callout + 12
22  libdispatch.dylib                    0x00000001809a8ad4 _dispatch_queue_serial_drain + 924
23  libdispatch.dylib                    0x000000018099e2cc _dispatch_queue_invoke + 880
24  libdispatch.dylib                    0x00000001809a8fa8 _dispatch_queue_override_invoke + 340
25  libdispatch.dylib                    0x00000001809aaa50 _dispatch_root_queue_drain + 536
26  libdispatch.dylib                    0x00000001809aa7d0 _dispatch_worker_thread3 + 120
27  libsystem_pthread.dylib              0x0000000180ba31d0 _pthread_wqthread + 1092
28  libsystem_pthread.dylib              0x0000000180ba2d7c start_wqthread + 0

我要尝试的操作每隔5或10秒从服务器获取一些新闻头条,然后使用NSSortDescriptors对其进行排序,然后将其存储在我的CoreData中。这正是 saveHeadlines:block 方法在我的类中所做的事情。

What i am trying to do is get some news headlines from server every 5 or 10 secs, sort them in some order using NSSortDescriptors and then store them in my CoreData. And that is what exactly saveHeadlines:block method is doing inside my class.

objc_msgSend()选择器名称:长度
是这里吗?感谢您的帮助。

What exactly objc_msgSend() selector name: length mean here? Any help is appreciated.

注意:这是一个零星的问题。当我在模拟器或设备中进行测试时,它不会崩溃。但是我们应用的某些用户报告了此崩溃。

Note: Its a sporadic issue. When i test in simulator or my devices its not crashing. But some users of our app are reporting this crash.

已修改的问题:在saveHeadlines:block方法内

Edited question: inside saveHeadlines:block method

        __weak typeof(self) weakSelf = self;
    [self.privateMOC performBlock:^{

        NSMutableArray *newsTopics = [[EIKNewsTopicStoreManager managedObjectsInManagedObjectContext:self.privateMOC] mutableCopy];
        [newsTopics addObjectsFromArray:[EIKNewsTopicStoreManager topicsManagedObjectForNewsFeedInContext:self.privateMOC]];
        weakSelf.storedHeadlines = [NSMutableSet set];

        for (NSManagedObject *storedTopic in newsTopics) {
            [weakSelf.storedHeadlines addObjectsFromArray:[[storedTopic valueForKey:EIKFeedTopicRelationshipItems] allObjects]];
        }

        NSArray *sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:EIKNewsHeadlineAttributeHeadlineId ascending:YES]];
        NSArray *orderedItems = [items sortedArrayUsingDescriptors:sortDescriptors];
        NSArray *orderedHeadlines = [weakSelf.storedHeadlines sortedArrayUsingDescriptors:sortDescriptors];

崩溃发生在最后一行。即

And the crash is happening on the last line. i.e

 NSArray *orderedHeadlines = [weakSelf.storedHeadlines sortedArrayUsingDescriptors:sortDescriptors];

无法弄清原因。!

我的NSManagedObjectContext这样初始化[即,如上面代码中所示的privateMOC]

My NSManagedObjectContext is initialised like this[i.e privateMOC as shown in above code]

NSManagedObjectContext *confinementContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];


推荐答案

此处信息不多,但在我看来 NSManagedObjectContext 在您正在执行操作的线程上无效。
请确保对上下文的专用队列执行所有操作。例如,可以使用 performBlock: performBlockAndWait:来执行此操作。
另外,您不能在与获取它们的线程不同的线程上重用 NSManagedObject 的实例。
希望有帮助。

Not much info here, but it looks to me that NSManagedObjectContext isn't valid on the thread you are performing your operation. Please make sure that you perform all operations on the context's private queue. You can do this for example by using performBlock: or performBlockAndWait:. Also you can't reuse instances of NSManagedObject on different threads than the one you fetched them on. Hope that helps.

这篇关于SIGSEGV:零星的崩溃问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆