领域,commitWriteTransaction,EXC_BAD_ACCESS KERN_PROTECTION_FAILURE

时间:2016-03-01 13:06:08

标签: realm

当我使用Realm存储我的数据时,就像

一样
[applicat.realm beginWriteTransaction];

NSArray *bankCards = [XXXBankCard createOrUpdateInRealm:applicat.realm withJSONArray:cards];
[applicat.bankCards removeAllObjects];
[applicat.bankCards addObjects:bankCards];

[applicat.realm commitWriteTransaction];

我的Fabric获得了很多崩溃

  

崩溃:com.apple.main-thread EXC_BAD_ACCESS KERN_PROTECTION_FAILURE   0x0000000108ad421c

applicatXXXApplicat的实例:

@interface XXXApplicat : RLMObject
@property(nonatomic, copy) NSString * uid;
@property(nonatomic, strong) RLMArray<XXXBankCard> * bankCards;
@end

applicat.realm等于applicat.bankCards.realm。我初始化applicat的地方是:

- (XXXApplicat *)applicat {
    if (self.realm == nil) {
        return nil;
    }

    if (_applicat == nil) {
        _applicat = [XXXApplicat objectInRealm:self.realm forPrimaryKey:self.userId];

        if (_applicat == nil) {
            _applicat = [XXXApplicat new];
            _applicat.uid = self.userId;

            [self.realm beginWriteTransaction];
            [self.realm addObject:_applicat];
            [self.realm commitWriteTransaction];
        }

        [self addObserverToApplicat:_applicat];
    }

    return _applicat;
}

整个崩溃日志是:

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_PROTECTION_FAILURE 0x0000000107448000

Thread : Crashed: com.apple.main-thread
0  XXX                   0x100491c28 realm::_impl::WriteLogCollector::do_prepare_commit(realm::SharedGroup&, unsigned long long) + 2696
1  XXX                   0x100491c1c realm::_impl::WriteLogCollector::do_prepare_commit(realm::SharedGroup&, unsigned long long) + 2684
2  XXX                   0x1004243c0 realm::SharedGroup::do_commit() + 7828
3  XXX                   0x100292174 realm::SharedGroup::commit_and_continue_as_read() + 60 (group_shared.hpp:938)
4  XXX                   0x10028f948 -[RLMRealm commitWriteTransaction:] + 12452 (RLMRealm.mm:612)
5  XXX                   0x1000d9c44 -[XXXInfoCollectionManager handleBankCards:] (XXXInfoCollectionManager.m:143)
6  XXX                   0x1000d99ec __43-[XXXInfoCollectionManager updateBankCards]_block_invoke (XXXInfoCollectionManager.m:127)
7  XXX                   0x100173f18 -[XXXHttpRequestManager handleXXXHttpOperation:object:successHandler:] (XXXHttpRequestManager.m:662)
8  XXX                   0x100172aa8 __56-[XXXHttpRequestManager GET:parameters:success:failure:]_block_invoke (XXXHttpRequestManager.m:542)
9  XXX                   0x1001720b4 __73-[XXXHttpRequestManager HTTPRequestOperationWithRequest:success:failure:]_block_invoke (XXXHttpRequestManager.m:490)
10 libdispatch.dylib              0x1817cd630 _dispatch_call_block_and_release + 24
11 libdispatch.dylib              0x1817cd5f0 _dispatch_client_callout + 16
12 libdispatch.dylib              0x1817d2cf8 _dispatch_main_queue_callback_4CF + 1844
13 CoreFoundation                 0x181d30bb0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
14 CoreFoundation                 0x181d2ea18 __CFRunLoopRun + 1628
15 CoreFoundation                 0x181c5d680 CFRunLoopRunSpecific + 384
16 GraphicsServices               0x18316c088 GSEventRunModal + 180
17 UIKit                          0x186ad4d90 UIApplicationMain + 204
18 XXX                   0x1000b5ec8 main (main.m:75)
19 libdispatch.dylib              0x1817fe8b8 (Missing)

1 个答案:

答案 0 :(得分:1)

您看到的崩溃是an issue in older versions of Realm Objective-C。它在v0.97.0中修复。更新到较新版本的Realm应解决此崩溃问题。