Roobiq / RBQFetchedResultsController

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

v4.0.1 crashes #86

Closed thonydam closed 8 years ago

thonydam commented 8 years ago

Hey,

I have tested 4.0.1 and now I get a crash: Index is out of bounds

bigfish24 commented 8 years ago

Can you break point and tell me what index it is trying to grab and how out of bounds that is?

thonydam commented 8 years ago

I have not been able to reproduce the crash contantly

Here is the stack trace i am getting:
[26992:266928] *** Terminating app due to uncaught exception 'RLMException', reason: 'Index 9223372036854775808 is out of bounds (must be less than 4)'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010bb69d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010b5d8deb objc_exception_throw + 48
    2   Realm                               0x000000010a5b60f4 _ZL10throwErrorv + 276
    3   Realm                               0x000000010a5b3b05 -[RLMArrayLinkView objectAtIndex:] + 80
    4   RBQFetchedResultsController         0x000000010a441311 -[RBQFetchedResultsController safeObjectsFromChanges:withCollection:isInsertion:] + 622
    5   RBQFetchedResultsController         0x000000010a441c80 __58-[RBQFetchedResultsController registerChangeNotifications]_block_invoke_2.383 + 342
    6   Realm                               0x000000010a5b9204 _ZZ23RLMAddNotificationBlockIN5realm7ResultsEEP20RLMNotificationTokenP11objc_objectRT_U13block_pointerFvS5_P19RLMCollectionChangeP7NSErrorEbENUlRKNS0_19CollectionChangeSetESt13exception_ptrE_clESG_SH_ + 350```
thonydam commented 8 years ago

Since updating to realm 0.99.1 and latest RBQ,

The CPU usage became abnormal, the RLMRealm notification listener thread is using 100% of the CPU. I'm trying to see where this is coming from.

ksi1024 commented 8 years ago

Hi, I'm having the same issue. It crashed when I deleted an object. It seems the RBQSectionCacheObject.firstObjectIndex is not set properly when RBQFetchedResultsController is initialized with sectionNameKeyPath set to nil for single section.

denis-hoz commented 8 years ago

Hi, I have idea. Does this correct fix?

NSUInteger row = index.unsignedIntegerValue;
if (self.sectionNameKeyPath) {
    row -= section.firstObjectIndex;
}

At -[RBQFetchedResultsController safeObjectsFromChanges:withCollection:isInsertion:]

UPD :

https://github.com/denis-hoz/RBQFetchedResultsController/commit/0cc15e2c5d0f8c05ad661a1871ed9f831c1f9b84

bigfish24 commented 8 years ago

Will fix this today, sorry about the issue!

bigfish24 commented 8 years ago

Fixed in: https://github.com/Roobiq/RBQFetchedResultsController/releases/tag/v4.0.3

Note that you should only use RBQFRC if you want the section capabilities. If you don't need this, just use Realm's fine-grained notifications directly: https://realm.io/news/realm-objc-swift-0.99.0/