Uploaded image for project: 'Realm Cocoa SDK'
  1. Realm Cocoa SDK
  2. RCOCOA-1377

Crash when initiating transaction after object on which an observer was registered is deleted from realm

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: None

      After updating RealmSwift from 10.9.0 to 10.11.0, there is a bug where, after deleting an object on which an observer is registered, the next write transaction will crash the program.

      This definitely worked up until 10.9 (not sure about 10.10, but it's broken after updating to 10.11).

      Code Sample

      Sample Xcode project.

      Simply run the app and tap the button to cause it to crash.

      Version of Realm and Tooling

      • Realm framework version: RealmSwift SPM Package v10.11.0
      • Xcode version: 12.5.1 (12E507)
      • iOS/OSX version: macOS 11.5.1 (20G80), iOS 14.7.1 (18G82)
      • Dependency manager + version: SPM, the one shipped w/ the above-specified Xcode version

      Backtrace

      (lldb) bt all
        thread #1, queue = 'com.apple.main-thread'
          frame #0: 0x00000001cd82a908 libsystem_kernel.dylib`mach_msg_trap + 8
          frame #1: 0x00000001cd829d0c libsystem_kernel.dylib`mach_msg + 72
          frame #2: 0x00000001a1fe3db8 CoreFoundation`__CFRunLoopServiceMachPort + 368
          frame #3: 0x00000001a1fde1b8 CoreFoundation`__CFRunLoopRun + 1184
          frame #4: 0x00000001a1fdd7d0 CoreFoundation`CFRunLoopRunSpecific + 572
          frame #5: 0x00000001b871f570 GraphicsServices`GSEventRunModal + 160
          frame #6: 0x00000001a490a2d0 UIKitCore`-[UIApplication _run] + 1052
          frame #7: 0x00000001a490f84c UIKitCore`UIApplicationMain + 164
          frame #8: 0x00000001b513487c libswiftUIKit.dylib`UIKit.UIApplicationMain(Swift.Int32, Swift.Optional<Swift.UnsafeMutablePointer<Swift.UnsafeMutablePointer<Swift.Int8>>>, Swift.Optional<Swift.String>, Swift.Optional<Swift.String>) -> Swift.Int32 + 100
          frame #9: 0x000000010295a19c LKRealmCrashTest`static UIApplicationDelegate.main() at <compiler-generated>:0
          frame #10: 0x000000010295a114 LKRealmCrashTest`static AppDelegate.$main(self=LKRealmCrashTest.AppDelegate) at AppDelegate.swift:10:1
          frame #11: 0x000000010295a234 LKRealmCrashTest`main at <compiler-generated>:0
          frame #12: 0x00000001a1cbc140 libdyld.dylib`start + 4
        thread #4
          frame #0: 0x00000001e99d4864 libsystem_pthread.dylib`start_wqthread
        thread #5, name = 'com.apple.uikit.eventfetch-thread'
          frame #0: 0x00000001cd82a908 libsystem_kernel.dylib`mach_msg_trap + 8
          frame #1: 0x00000001cd829d0c libsystem_kernel.dylib`mach_msg + 72
          frame #2: 0x00000001a1fe3db8 CoreFoundation`__CFRunLoopServiceMachPort + 368
          frame #3: 0x00000001a1fde1b8 CoreFoundation`__CFRunLoopRun + 1184
          frame #4: 0x00000001a1fdd7d0 CoreFoundation`CFRunLoopRunSpecific + 572
          frame #5: 0x00000001a323ae64 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 228
          frame #6: 0x00000001a323ad44 Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 88
          frame #7: 0x00000001a49b6e10 UIKitCore`-[UIEventFetcher threadMain] + 504
          frame #8: 0x00000001a3397d90 Foundation`__NSThread__start__ + 848
          frame #9: 0x00000001e99cfc74 libsystem_pthread.dylib`_pthread_start + 288
      * thread #9, name = 'Realm notification listener', stop reason = signal SIGABRT
          frame #0: 0x00000001cd84e7b0 libsystem_kernel.dylib`__pthread_kill + 8
          frame #1: 0x00000001e99d09c0 libsystem_pthread.dylib`pthread_kill + 212
          frame #2: 0x00000001aac9ca38 libsystem_c.dylib`abort + 120
        * frame #3: 0x00000001036a2b5c LKRealmCrashTest`::please_report_this_issue_in_github_realm_realm_core() at terminate.cpp:50:5
          frame #4: 0x00000001036a2ec4 LKRealmCrashTest`realm::util::terminate_internal(ss=0x000000016d90a608) at terminate.cpp:123:5
          frame #5: 0x00000001036a2fc4 LKRealmCrashTest`realm::util::terminate(message="Assertion failed: m_table", file="/Users/lukas/Library/Developer/Xcode/DerivedData/LKRealmCrashTest-bnxdefajsfeddrbvaxnfxmktpmfk/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/object_notifier.cpp", line=55, values=0x000000016d90a788) at terminate.cpp:140:5
          frame #6: 0x0000000102fc4c30 LKRealmCrashTest`realm::_impl::ObjectNotifier::do_add_required_change_info(this=0x0000000106b16088, info=0x00000002818a9a40) at object_notifier.cpp:55:9
          frame #7: 0x0000000102f8c334 LKRealmCrashTest`realm::_impl::CollectionNotifier::add_required_change_info(this=0x0000000106b16088, info=0x00000002818a9a40) at collection_notifier.cpp:245:10
          frame #8: 0x0000000102fcff84 LKRealmCrashTest`realm::_impl::RealmCoordinator::run_async_notifiers(this=0x0000000106a0b438) at realm_coordinator.cpp:1059:19
          frame #9: 0x0000000102fcf40c LKRealmCrashTest`realm::_impl::RealmCoordinator::on_change(this=0x0000000106a0b438) at realm_coordinator.cpp:818:5
          frame #10: 0x0000000102f63254 LKRealmCrashTest`realm::_impl::ExternalCommitHelper::listen(this=0x00000002835deeb0) at external_commit_helper.cpp:234:18
          frame #11: 0x0000000102f665c8 LKRealmCrashTest`realm::_impl::ExternalCommitHelper::ExternalCommitHelper(this=0x0000000283988ba8)::$_0::operator()() const at external_commit_helper.cpp:175:13
          frame #12: 0x0000000102f66564 LKRealmCrashTest`decltype(__f=0x0000000283988ba8)::$_0>(fp)()) std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) at type_traits:3747:1
          frame #13: 0x0000000102f664c4 LKRealmCrashTest`void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(__t=size=2, (null)=__tuple_indices<> @ 0x000000016d90af6f)::$_0>&, std::__1::__tuple_indices<>) at thread:280:5
          frame #14: 0x0000000102f65bc8 LKRealmCrashTest`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >(__vp=0x0000000283988ba0) at thread:291:5
          frame #15: 0x00000001e99cfc74 libsystem_pthread.dylib`_pthread_start + 288
      (lldb) 
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: