crashlytics用nsoperationqueue崩溃(QoS:未指定)



我正在崩溃,在crashlytics中报告,我不知道如何重现错误,它会随机发生,因此很难用Xcode进行调试。有什么想法吗?

Crashed: NSOperationQueue 0x280419200 (QOS: UNSPECIFIED)
0 libobjc.A.dylib 0x22c471430 objc_retain + 16
1 CoreFoundation 0x22d2b5888 __CFBasicHashAddValue + 1480
2 CoreFoundation 0x22d1e64ac CFDictionarySetValue + 260
3 Foundation 0x22dd04888 _encodeObject + 732
4 myAPI 0x1062b44b0 -[DataCore encodeWithCoder:] (DataCore.m:236)
5 myAPI 0x1062909c4 -[DataHandle encodeWithCoder:] (DataHandle.m:53)
6 Foundation 0x22dd04aa8 _encodeObject + 1276
7 Foundation 0x22dc69c6c +[NSKeyedArchiver archivedDataWithRootObject:] + 168
8 myAPI 0x106288a34 __77+[CachableObject addObjectToCache:withCacheName:withTTL:withCompletionBlock:]_block_invoke (CachableObject.m:162)
9 Foundation 0x22dd198bc NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 16
10 Foundation 0x22dc21ab8 -[NSBlockOperation main] + 72
11 Foundation 0x22dc20f8c -[__NSOperationInternal _start:] + 740
12 Foundation 0x22dd1b790 __NSOQSchedule_f + 272
13 libdispatch.dylib 0x22ccc16c8 _dispatch_call_block_and_release + 24
14 libdispatch.dylib 0x22ccc2484 _dispatch_client_callout + 16
15 libdispatch.dylib 0x22cc6582c _dispatch_continuation_pop$VARIANT$mp + 412
16 libdispatch.dylib 0x22cc64ef4 _dispatch_async_redirect_invoke + 600
17 libdispatch.dylib 0x22cc71a18 _dispatch_root_queue_drain + 376
18 libdispatch.dylib 0x22cc722c0 _dispatch_worker_thread2 + 128
19 libsystem_pthread.dylib 0x22cea517c _pthread_wqthread + 472
20 libsystem_pthread.dylib 0x22cea7cec start_wqthread + 4

这是datacore.m中的代码

中的代码
- (void)encodeWithCoder:(NSCoder *)coder {
    [super encodeWithCoder:coder];
    [coder encodeObject:programFormatPlayInfo forKey:@"ProgramFormatPlayInfo"];
    [coder encodeObject:bigScreenPlayInfo forKey:@"BigScreenPlayInfo"];
    [coder encodeObject:pivotHandle forKey:@"PivotHandle"];
    [coder encodeInteger:pivotDataLinkId forKey:@"PivotDataLinkId"];
    [coder encodeInteger:viewContextId forKey:@"ViewContextId"];
    [coder encodeBool:suppressImagePivot forKey:@"SuppressImagePivot"];
    [coder encodeObject:attributeIds forKey:@"AttributeIds"];
    [coder encodeObject:self.overflow forKey:@"Overflow"];
    [coder encodeObject:self.cacheNameWithUser forKey:@"CacheNameWithUser"];
    [coder encodeObject:self.metaData forKey:@"Metadata"];
}

,这是我尝试在缓存中添加对象的地方,不确定它是无法解码还是与背景队列有关的内容。

+ (void)addObjectToCache:(CachableObject*)object withCacheName:(NSString*)cacheName withTTL:(CacheTime)cacheTimeSeconds withCompletionBlock:(void(^)()) block {
    CachableObject* theObject = object;
    [_backgroundQueue addOperationWithBlock:^{
        @autoreleasepool {
            @try {
                NSString * path = [CachableObject pathForCachedObject:cacheName];
                NSDate * date = [NSDate date];
                [object setCacheDate:date];
                [object setTtlSeconds:[NSNumber numberWithInteger:cacheTimeSeconds]];
                [object setApiVersion:APIVERSION];
                // Add to NSCache
                [[CachableObject objectCache] setObject:theObject forKey:cacheName];
                // Add to file system
                NSError* err = nil;
                NSData * data = [NSKeyedArchiver archivedDataWithRootObject:theObject];
                if (data) {
                    [data writeToFile:path options:NSDataWritingAtomic error:&err];
                }
                // Add to dynamic cache
                unwrapObjectAndComplyWithClass(object, [DataHandle class], ^(id unwrappedObject) {
                    DataHandle *objectUnwrapped = unwrappedObject;
                    DataFrame *objectFrame = objectUnwrapped.frame;
                    for (NSString *eachDependencyName in objectFrame.dependencies) {
                        [[VVIDynamicCacheManager sharedManager]addDependencyToStore:eachDependencyName withCacheName:cacheName];
                    }
                }, ^{
                   /*Not a data handle*/
                });
            } @catch (NSException* ex) {
                NSLog(@"CachableObject: got an exception %@", ex);
            } @finally {
                if (block) {
                    block();
                }
            }
        }
    }];
}

这里的一些想法。

首先,您正在使用 @try/@catch。我相信NSKeyedArchiver在应返回NSError对象时会引发异常。因此,也许这就是为什么您要这样做。但是,您必须记住, apple框架的无保证是例外的安全。这意味着捕获异常可以在不一致的状态下将Apple的代码(当然还有您自己的代码)留在将来可以阻止其正常工作的状态。

我强烈建议您删除@catch,或者在NSKeyedArchiver代码周围非常紧密地范围,如果您使用它。这可能是无意间将各种其他错误引入您的应用程序的。

现在,要进行特定的崩溃。它发生在运行时的内存管理代码中。这对堆腐败非常强烈。这意味着您有一个指针,该指针在内存中没有指向有效的Objective-C对象。这可能出于多种原因而发生,并且是极其常见的。最常见的原因称为悬空指针。但是,这也可能是由于过度发行而引起的。而且,如果可以使用@catch触发过度发行,我一点也不会感到惊讶。(我知道,我正在har在

我通常在这些情况下推荐的内容:

  • 寻找其他与堆积相关的崩溃
  • 在乐器中尝试Zombies
  • 尝试malloc scribble或Guardmalloc,另外两个好的内存调试工具

推理堆积腐败是困难的,而且通常是不可能的。复制错误也可能是不可能的,因为内存腐败通常不是确定性的。

所以,只需尝试找到并解决尽可能多的问题即可。其中一个完全有可能负责各种崩溃,其中之一可能是。

相关内容

  • 没有找到相关文章

最新更新