Roobiq / RBQFetchedResultsController

Drop-in replacement for NSFetchedResultsController backed by Realm.
MIT License
476 stars 70 forks source link

Crash when deleting sectioned objects. #116

Closed anlaital closed 7 years ago

anlaital commented 7 years ago

5.0.1 crashes with the following stack trace when deleting objects:

2016-12-22 22:04:27.251 RBQFRCSwiftExample[6517:3716248] *** Terminating app due to uncaught exception 'RLMException', reason: 'Index 0 is out of bounds (must be less than 0)'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000108451d4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000107eb321e objc_exception_throw + 48
    2   Realm                               0x0000000106f9e94b _ZL10throwErrorv + 379
    3   Realm                               0x0000000106f9a66a _ZL15translateErrorsIZ34-[RLMArrayLinkView objectAtIndex:]E3$_3EDaOT_ + 58
    4   Realm                               0x0000000106f9a612 -[RLMArrayLinkView objectAtIndex:] + 82
    5   RBQFetchedResultsController         0x0000000106e552fc -[RBQFetchedResultsController safeObjectsFromChanges:withCollection:isInsertion:] + 972
    6   RBQFetchedResultsController         0x0000000106e56174 __58-[RBQFetchedResultsController registerChangeNotifications]_block_invoke_2.393 + 324
    7   Realm                               0x0000000106fad135 _ZZ23RLMAddNotificationBlockIN5realm7ResultsEEP20RLMNotificationTokenP11objc_objectRT_U13block_pointerFvS5_P19RLMCollectionChangeP7NSErrorEbENKUlRKNS0_19CollectionChangeSetESt13exception_ptrE_clESG_SH_ + 741
    8   Realm                               0x0000000106facc34 _ZN5realm24CollectionChangeCallback4ImplIZ23RLMAddNotificationBlockINS_7ResultsEEP20RLMNotificationTokenP11objc_objectRT_U13block_pointerFvS7_P19RLMCollectionChangeP7NSErrorEbEUlRKNS_19CollectionChangeSetESt13exception_ptrE_E5afterESI_ + 52
    9   Realm                               0x0000000106ee5eda _ZN5realm24CollectionChangeCallback5afterERKNS_19CollectionChangeSetE + 58
    10  Realm                               0x0000000106ee5e45 _ZZN5realm5_impl18CollectionNotifier13after_advanceEvENK3$_9clINSt3__111unique_lockINS4_5mutexEEENS1_8CallbackEEEDaRT_RT0_ + 165
    11  Realm                               0x0000000106ecae41 _ZN5realm5_impl18CollectionNotifier17for_each_callbackIZNS1_13after_advanceEvE3$_9EEvOT_ + 273
    12  Realm                               0x0000000106ecad29 _ZN5realm5_impl18CollectionNotifier13after_advanceEv + 25
    13  Realm                               0x0000000106ecdb88 _ZN5realm5_impl15NotifierPackage13after_advanceEv + 456
    14  Realm                               0x00000001071a06dc _ZN12_GLOBAL__N_119TransactLogObserverC2IZN5realm5_impl11transaction7advanceERNS2_11SharedGroupEPNS2_14BindingContextENS2_10SchemaModeERNS3_15NotifierPackageEE3$_1EES8_S6_OT_NS2_4util8OptionalIS9_EESB_ + 1772
    15  Realm                               0x0000000107188dc5 _ZN12_GLOBAL__N_119TransactLogObserverC1IZN5realm5_impl11transaction7advanceERNS2_11SharedGroupEPNS2_14BindingContextENS2_10SchemaModeERNS3_15NotifierPackageEE3$_1EES8_S6_OT_NS2_4util8OptionalIS9_EESB_ + 53
    16  Realm                               0x0000000107188d7a _ZN5realm5_impl11transaction7advanceERNS_11SharedGroupEPNS_14BindingContextENS_10SchemaModeERNS0_15NotifierPackageE + 138
    17  Realm                               0x0000000106f48e7c _ZN5realm5_impl16RealmCoordinator16advance_to_readyERNS_5RealmE + 860
    18  Realm                               0x0000000107132e61 _ZN5realm5Realm6notifyEv + 449
    19  Realm                               0x00000001071c165b _ZN5realm5_impl17WeakRealmNotifier8CallbackclEv + 75
    20  Realm                               0x00000001071c24cc _ZZN5realm4util15EventLoopSignalINS_5_impl17WeakRealmNotifier8CallbackEEC1EOS4_ENKUlPvE_clES7_ + 28
    21  Realm                               0x00000001071c24a8 _ZZN5realm4util15EventLoopSignalINS_5_impl17WeakRealmNotifier8CallbackEEC1EOS4_ENUlPvE_8__invokeES7_ + 24
    22  CoreFoundation                      0x00000001083f6761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    23  CoreFoundation                      0x00000001083db98c __CFRunLoopDoSources0 + 556
    24  CoreFoundation                      0x00000001083dae76 __CFRunLoopRun + 918
    25  CoreFoundation                      0x00000001083da884 CFRunLoopRunSpecific + 420
    26  CoreFoundation                      0x0000000108415e11 CFRunLoopRun + 97
    27  RBQFetchedResultsController         0x0000000106e55a11 __58-[RBQFetchedResultsController registerChangeNotifications]_block_invoke + 193
    28  libdispatch.dylib                   0x000000010baf2978 _dispatch_call_block_and_release + 12
    29  libdispatch.dylib                   0x000000010bb1c0cd _dispatch_client_callout + 8
    30  libdispatch.dylib                   0x000000010bafd65f _dispatch_root_queue_drain + 1450
    31  libdispatch.dylib                   0x000000010bafd059 _dispatch_worker_thread3 + 123
    32  libsystem_pthread.dylib             0x000000010becb712 _pthread_wqthread + 1299
    33  libsystem_pthread.dylib             0x000000010becb1ed start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

This can easily be reproduced with the example Swift-cocoapods application.

  1. Press Delete in the upper left corner (deletes the first section)
  2. Swipe the first item in the second section (that is now the first section) and delete it
  3. Crash