Realm-cocoa: Assertion failed: real_ndx != detached_ref in 0.101.0

Created on 5 May 2016  路  3Comments  路  Source: realm/realm-cocoa

Goals

I want to use RLMLinkingObjects widely.

Expected Results

I expected to use RLMLinkingObjects safely anytime before deleting the instance that has the RLMLinkingObjects property.

Actual Results

core/include/realm/table_view.hpp:1425: [realm-core-0.100.0] Assertion failed: real_ndx != detached_ref
0   Backlink                            0x000000010022ee04 _ZN5realm4util18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 40
1   Backlink                            0x000000010022f02c _ZN5realm4util9terminateEPKcS2_l + 340
2   Backlink                            0x00000001000d5590 _ZN5realm9TableView3getEm + 204
3   Backlink                            0x00000001000d4cf8 _ZN5realm9TableViewixEm + 28
4   Backlink                            0x00000001000b0c04 _ZN5realm5_impl15ResultsNotifier17calculate_changesEv + 2356
5   Backlink                            0x00000001000b0e48 _ZN5realm5_impl15ResultsNotifier3runEv + 440
6   Backlink                            0x000000010008cfc0 _ZN5realm5_impl16RealmCoordinator19run_async_notifiersEv + 5816
7   Backlink                            0x000000010008b710 _ZN5realm5_impl16RealmCoordinator9on_changeEv + 40
8   Backlink                            0x000000010005d15c _ZN5realm5_impl20ExternalCommitHelper6listenEv + 672
9   Backlink                            0x000000010005dc04 _ZZN5realm5_impl20ExternalCommitHelperC1ERNS0_16RealmCoordinatorEENK3$_0clEv + 24
10  Backlink                            0x000000010005dbe0 _ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE + 64
11  Backlink                            0x000000010005db94 _ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEEclEv + 24
12  Backlink                            0x000000010005daa4 _ZNSt3__119__async_assoc_stateIvNS_12__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS3_16RealmCoordinatorEE3$_0JEEEE9__executeEv + 32
13  Backlink                            0x000000010005e328 _ZNSt3__114__thread_proxyINS_5tupleIJMNS_19__async_assoc_stateIvNS_12__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS5_16RealmCoordinatorEE3$_0JEEEEEFvvEPSB_EEEEEPvSG_ + 388
14  libsystem_pthread.dylib             0x0000000182fa7b28 <redacted> + 156
15  libsystem_pthread.dylib             0x0000000182fa7a8c <redacted> + 0
16  libsystem_pthread.dylib             0x0000000182fa5028 thread_start + 4
IMPORTANT: if you see this error, please send this log to [email protected].

image

Steps to Reproduce

  • Make a relationship like as _One-to-Many Relationships_ on https://realm.io/news/realm-objc-swift-0.100.0/
  • Read a RLMLinkingObjects property
  • Delete the instances that has the property
  • Do anything for 10 milliseconds or so without doing anything about the deleted instances.
  • Xcode shows 'Assertion failed'

    Code Sample

@class Person;

@interface Dog : RLMObject
@property NSString *name;
@property Person *owner;
@end

@implementation Dog
@end

@interface Person : RLMObject
@property NSString *name;
@property (readonly) RLMLinkingObjects<Dog *> *dogs;
@end

@implementation Person
+ (NSDictionary *)linkingObjectsProperties {
    return @{
             @"dogs": [RLMPropertyDescriptor descriptorWithClass:Dog.class propertyName:@"owner"],
             };
}
@end

...

-(void)foo {
    Person *john = [[Person alloc] initWithValue:@[@"John"]];
    Dog *fido = [[Dog alloc] initWithValue:@[@"Fido", john]];

    RLMRealm *realm = [RLMRealm defaultRealm];
    [realm transactionWithBlock:^{
        [realm addObject:fido];
        [realm addObject:john];
    }];

    RLMLinkingObjects *dogsOfJohn = john.dogs;
    NSLog(@"%@", dogsOfJohn);

    [realm transactionWithBlock:^{
        [realm deleteObject:fido];
        [realm deleteObject:john];
    }];

    [NSThread sleepForTimeInterval:0.01];
}

Version of Realm and Tooling

Realm version: 0.101.0.(67499adc2a5da5344d2f60c9069145e08b285612)

Xcode version: 7.3.1

iOS version: 9.3.1

I didn't use any dependency manager for above code. I modified AppDelegate.m of Backlink in examples/ios/objc folder.

T-Bug-Crash

Most helpful comment

Thanks, it works quite well in 0.102.0 :smile:

All 3 comments

Thanks for the great bug report!

I've pinpointed the problem in Realm's core and have submitted a fix.

Thanks, it works quite well in 0.102.0 :smile:

Was this page helpful?
0 / 5 - 0 ratings