realm-swift: Crash in RLMObservationInfo::didChange(NSString*, NSKeyValueChange, NSIndexSet*) const (RLMObservation.hpp:116)

Hi!

I’m currently experiencing the following crash when trying to KVO observe objects invalidated property in my Realm. All the registering for the observations is done on the main thread. Any idea what could be wrong?

The crash specifically seems to occur when calling RLMRealm.defaultRealm().refresh() on the main thread and only in Release builds. Debug is running fine!

Thread : Crashed: com.apple.main-thread
0  MyApp                       0x0000000100718fc4 RLMObservationInfo::didChange(NSString*, NSKeyValueChange, NSIndexSet*) const (RLMObservation.hpp:116)
1  MyApp                       0x000000010071adb8 (anonymous namespace)::TransactLogHandler::notifyObservers() (RLMObservation.mm:473)
2  MyApp                       0x0000000100719e6c RLMAdvanceRead(realm::SharedGroup&, realm::History&, RLMSchema*) (RLMObservation.mm:503)
3  MyApp                       0x0000000100743d74 -[RLMRealm handleExternalCommit] (RLMRealm.mm:738)
4  MyApp                       0x00000001007488f0 -[RLMNotifier listen]::$_1::__invoke(void*) (RLMRealmUtil.mm:249)
5  CoreFoundation                 0x0000000182753f8c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
6  CoreFoundation                 0x0000000182753230 __CFRunLoopDoSources0 + 264
7  CoreFoundation                 0x00000001827512e0 __CFRunLoopRun + 712
8  CoreFoundation                 0x000000018267cf74 CFRunLoopRunSpecific + 396
9  GraphicsServices               0x000000018c0d76fc GSEventRunModal + 168
10 UIKit                          0x000000018727ed94 UIApplicationMain + 1488
11 MyApp                       0x000000010014a398 main (main.m:33)
12 libdyld.dylib                  0x0000000194b1aa08 start + 4

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Comments: 23 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@tgoyne @jpsim UPD: this night spent not for nothing. Demo repo from above updated. Now it crashes in 100% runs for me. My observation is:

  • it crashes when main runloop paused (it happens during UITableView deceleration animation for example) and we update and delete same object. It looks like KVO-handling on main thread runs on invalidated object then (after main runloop resumed).

Please let me know if I can help with something.