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

Realm init crash - realm::Table::migrate_indexes - app update from RealmSwift 3.21.0 to 5.2.0

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None

      Goals

      Initialize Realm on app update without crashing.

      Expected Results

      After updating to our latest release, users are able to launch app and initialize Realm without crashing.

      Actual Results

      About 4% of users updating to our most recent release are crashing on launch. They will crash 100% of the time if they fall into this bucket. Our prior release was integrated with RealmSwift 3.21.0 and we updated to RealmSwift 5.2.0. No migrations as part of this update.

      Stack Trace:

      Unable to find source-code formatter for language: crashed. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      0  libsystem_kernel.dylib         0x18334b0dc __pthread_kill + 8
      1  libsystem_pthread.dylib        0x1833c4094 pthread_kill$VARIANT$mp + 380
      2  libsystem_c.dylib              0x1832a3ea8 abort + 140
      3  Our App                  0x101707ff4 std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char) + 190000
      4  Our App                  0x101708164 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 190368
      5  Our App                  0x1017082dc realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 190744
      6  Our App                  0x10128cc94 realm::util::FunctionRef<void (realm::BPlusTreeNode*, unsigned long)>::FunctionRef<realm::BPlusTree<float>::set(unsigned long, float)::'lambda'(realm::BPlusTreeNode*, unsigned long)&>(float&&)::'lambda'(void*, realm::BPlusTreeNode*, unsigned long)::__invoke(void*, realm::BPlusTreeNode*, unsigned long) + 63 (function_ref.hpp:63)
      7  Our App                  0x1015cdf3c realm::Array::move(unsigned long, unsigned long, unsigned long) + 2316628
      8  Our App                  0x1016d1b78 realm::Table::migrate_indexes(realm::ColKey, realm::util::FunctionRef<void ()>) + 143392
      9  Our App                  0x10165f92c realm::Transaction::upgrade_file_format(int) + 562396
      10 Our App                  0x1016684c0 realm::DB::upgrade_file_format(bool, int, int, int) + 598128
      11 Our App                  0x101666248 realm::DB::do_open(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, realm::DBOptions) + 589304
      12 Our App                  0x101668ae0 realm::DB::open(realm::Replication&, realm::DBOptions) + 599696
      13 Our App                  0x10166c918 realm::DB::create(realm::Replication&, realm::DBOptions) + 615624
      14 Our App                  0x1012a98b0 realm::_impl::RealmCoordinator::open_db() + 133184
      15 Our App                  0x1012a8bfc realm::_impl::RealmCoordinator::do_get_realm(realm::Realm::Config, std::__1::shared_ptr<realm::Realm>&, realm::util::Optional<realm::VersionID>, realm::util::CheckedUniqueLock&) + 129932
      16 Our App                  0x1012a8a90 realm::_impl::RealmCoordinator::get_realm(realm::Realm::Config, realm::util::Optional<realm::VersionID>) + 129568
      17 Our App                  0x10137cef0 realm::Realm::get_shared_realm(realm::Realm::Config) + 187 (shared_realm.hpp:187)
      18 Our App                  0x10134cccc +[RLMRealm realmWithConfiguration:queue:error:] + 4216 (memory:4216)
      19 Our App                  0x1013c43c8 Realm.init(queue:) + 179680 (<compiler-generated>:179680)
      20 Our App                  0x100f78a3c NotificationsRepository.loadNotifications(refresh:) + 31 (NotificationsRepository.swift:31)
      21 Our App                  0x100f3355c partial apply for thunk for @escaping @callee_guaranteed () -> (@owned Observable<[Notification]>, @error @owned Error) + 4305007964 (<compiler-generated>:4305007964)
      22 Our App                  0x1014b0d78 MapSwitchSink.performMap(_:) + 198 (Switch.swift:198)
      23 Our App                  0x1014b044c SwitchSink.on(_:) + 79 (Switch.swift:79)
      24 Our App                  0x1014b08e8 protocol witness for ObserverType.on(_:) in conformance SwitchSink<A, B, C> + 1147648 (<compiler-generated>:1147648)
      25 Our App                  0x10148fbd0 partial apply + 1013224 (<compiler-generated>:1013224)
      26 Our App                  0x1014a6d88 thunk for @escaping @callee_guaranteed (@in_guaranteed Event<A>) -> () + 1107872 (<compiler-generated>:1107872)
      27 Our App                  0x10149556c PublishSubject.on(_:) + 14 (Bag+Rx.swift:14)
      28 Our App                  0x101496694 protocol witness for ObserverType.on(_:) in conformance PublishSubject<A> + 1040556 (<compiler-generated>:1040556)
      29 Our App                  0x10148f964 ObserverType.onNext(_:) + 30 (ObserverType.swift:30)
      30 Our App                  0x100f478d8 AppDelegate.initLoadRemoteData() + 171 (AppDelegate.swift:171)
      31 Our App                  0x100f4724c AppDelegate.application(_:didFinishLaunchingWithOptions:) + 75 (AppDelegate.swift:75)
      32 Our App                  0x100f4740c @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 4305089548 (<compiler-generated>:4305089548)
      33 UIKitCore                      0x1aff940f0 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 412
      34 UIKitCore                      0x1aff95854 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3352
      35 UIKitCore                      0x1aff9afe0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1540
      36 UIKitCore                      0x1af85e2a4 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 776
      37 UIKitCore                      0x1af86683c +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160
      38 UIKitCore                      0x1af85df28 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236
      39 UIKitCore                      0x1af85e818 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1064
      40 UIKitCore                      0x1af85cb64 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 744
      41 UIKitCore                      0x1af85c82c -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 428
      42 UIKitCore                      0x1af86136c __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220
      43 UIKitCore                      0x1af862150 _performActionsWithDelayForTransitionContext + 112
      44 UIKitCore                      0x1af861224 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 244
      45 UIKitCore                      0x1af865f24 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 360
      46 UIKitCore                      0x1aff995e8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540
      47 UIKitCore                      0x1afb95e04 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
      48 FrontBoardServices             0x18612b9fc -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 440
      49 FrontBoardServices             0x18613540c __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 256
      50 FrontBoardServices             0x186134c14 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 64
      51 libdispatch.dylib              0x1831ed7d4 _dispatch_client_callout + 16
      52 libdispatch.dylib              0x1831925dc _dispatch_block_invoke_direct$VARIANT$mp + 224
      53 FrontBoardServices             0x186166040 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
      54 FrontBoardServices             0x186165cdc -[FBSSerialQueue _performNext] + 408
      55 FrontBoardServices             0x186166294 -[FBSSerialQueue _performNextFromRunLoopSource] + 52
      56 CoreFoundation                 0x183740f1c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
      57 CoreFoundation                 0x183740e9c __CFRunLoopDoSource0 + 88
      58 CoreFoundation                 0x183740784 __CFRunLoopDoSources0 + 176
      59 CoreFoundation                 0x18373b6c0 __CFRunLoopRun + 1004
      60 CoreFoundation                 0x18373afb4 CFRunLoopRunSpecific + 436
      61 GraphicsServices               0x18593c79c GSEventRunModal + 104
      62 UIKitCore                      0x1aff9cc38 UIApplicationMain + 212
      63 Our App                  0x100ef075c main + 19 (SelectItemViewModel.swift:19)
      64 libdyld.dylib                  0x1831fe8e0 start + 4
      

      Steps to Reproduce

      Launch app after updating. Haven't been able to reproduce locally.

      Code Sample

      App is crashing the first time we hit this line:

      let realm = try! Realm()

      This is our Realm Configuration in use:

      var config = Realm.Configuration(
                  schemaVersion: 105,
                  migrationBlock: { migration, oldSchemaVersion in
                      if (oldSchemaVersion < 105) {
                          migration.deleteData(forType: Notification.className())
                      }
      })
      config.fileURL = config.fileURL!.deletingLastPathComponent().appendingPathComponent("db5.realm")
      Realm.Configuration.defaultConfiguration = config
      

      Version of Realm and Tooling

      Realm framework version: 5.2.0
      Xcode version: 11.5
      iOS/OSX version: iOS 13.5.1
      Dependency manager + version: Cocoapods 1.9.3

            Assignee:
            jorgen.edelbo@mongodb.com Jørgen Edelbo
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: