realm-swift: Crash in realm::Array::init_from_mem(realm::MemRef)

Question:

I am seeing a realm::Array::init_from_mem(realm::MemRef) crash in production. I am unable to reproduce it my self. Does anyone have an idea what could cause this? Realm version 4.4.1

Actual Results

Crashed: com.apple.main-thread
0   Realm                          0x105e35af4 realm::Array::init_from_mem(realm::MemRef) + 28
1   Realm                          0x105ed349c realm::Group::attach(unsigned long, bool) + 112
2   Realm                          0x105edfdd8 realm::SharedGroup::begin_read(realm::VersionID) + 88
3   Realm                          0x105edcf64 realm::SharedGroup::do_open(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, realm::SharedGroupOptions) + 3608
4   Realm                          0x105e06cb8 realm::SharedGroup::open(realm::Replication&, realm::SharedGroupOptions) + 1421 (string:1421)
5   Realm                          0x105e0694c realm::SharedGroup::SharedGroup(realm::Replication&, realm::SharedGroupOptions) + 1421 (string:1421)
6   Realm                          0x105dffffc realm::Realm::open_with_config(realm::Realm::Config const&, std::__1::unique_ptr<realm::Replication, std::__1::default_delete<realm::Replication> >&, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> >&, std::__1::unique_ptr<realm::Group, std::__1::default_delete<realm::Group> >&, realm::Realm*) + 1421 (string:1421)
7   Realm                          0x105dff9f8 realm::Realm::Realm(realm::Realm::Config, std::__1::shared_ptr<realm::_impl::RealmCoordinator>) + 2637 (memory:2637)
8   Realm                          0x105d33a54 realm::Realm::make_shared_realm(realm::Realm::Config, std::__1::shared_ptr<realm::_impl::RealmCoordinator>)::make_shared_enabler::make_shared_enabler(realm::Realm::Config, std::__1::shared_ptr<realm::_impl::RealmCoordinator>) + 4521 (memory:4521)
9   Realm                          0x105d33874 std::__1::shared_ptr<realm::Realm::make_shared_realm(realm::Realm::Config, std::__1::shared_ptr<realm::_impl::RealmCoordinator>)::make_shared_enabler> std::__1::shared_ptr<realm::Realm::make_shared_realm(realm::Realm::Config, std::__1::shared_ptr<realm::_impl::RealmCoordinator>)::make_shared_enabler>::make_shared<realm::Realm::Config, std::__1::shared_ptr<realm::_impl::RealmCoordinator> >(realm::Realm::Config&&, std::__1::shared_ptr<realm::_impl::RealmCoordinator>&&) + 4521 (memory:4521)
10  Realm                          0x105d2e328 realm::_impl::RealmCoordinator::do_get_realm(realm::Realm::Config, std::__1::shared_ptr<realm::Realm>&, std::__1::unique_lock<std::__1::mutex>&, bool) + 4230 (memory:4230)
11  Realm                          0x105d2e194 realm::_impl::RealmCoordinator::get_realm(realm::Realm::Config) + 186 (shared_realm.hpp:186)
12  Realm                          0x105e019e4 realm::Realm::get_shared_realm(realm::Realm::Config) + 186 (shared_realm.hpp:186)
13  Realm                          0x105dd0d78 +[RLMRealm realmWithConfiguration:error:] + 4217 (memory:4217)
14  RealmSwift                     0x106273d80 Realm.init() + 4331437440 (<compiler-generated>:4331437440)
15  App                         0x104b88f40 static Realm.create(retry:) + 13 (Realm.swift:13)
16  App                         0x104d986e8 closure #1 in closure #1 in static User.getUser() + 89 (User.swift:89)
17  libswiftObjectiveC.dylib       0x1e63f1d20 autoreleasepool<A>(invoking:) + 56
18  App                         0x104b439d8 specialized thunk for @escaping @callee_guaranteed (@guaranteed @escaping @callee_guaranteed (@guaranteed SingleEvent<User>) -> ()) -> (@out Disposable) + 4307204568 (<compiler-generated>:4307204568)
19  RxSwift                        0x1064829c0 partial apply for closure #1 in static PrimitiveSequenceType<>.create(subscribe:) + 39 (Single.swift:39)
20  RxSwift                        0x10644f444 AnonymousObservableSink.run(_:) + 60 (Create.swift:60)
21  RxSwift                        0x10644f668 AnonymousObservable.run<A>(_:cancel:) + 76 (Create.swift:76)
22  RxSwift                        0x10645e448 Producer.subscribe<A>(_:) + 18 (Producer.swift:18)
23  RxSwift                        0x106440258 ObservableType.subscribe(_:) + 25 (ObservableType+Extensions.swift:25)
24  RxSwift                        0x106482ce4 PrimitiveSequenceType<>.subscribe(_:) + 61 (Single.swift:61)
25  RxSwift                        0x10648320c PrimitiveSequenceType<>.subscribe(onSuccess:onError:) + 90 (Single.swift:90)
26  App                         0x104b43454 closure #1 in SessionController.initialiseUser() + 108 (SessionController.swift:108)
27  App                         0x104daced8 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed @escaping @callee_guaranteed (@guaranteed SingleEvent<User>) -> ()) -> (@out Disposable) + 4309733080 (<compiler-generated>:4309733080)
28  RxSwift                        0x1064829c0 partial apply for closure #1 in static PrimitiveSequenceType<>.create(subscribe:) + 39 (Single.swift:39)
29  RxSwift                        0x10644f444 AnonymousObservableSink.run(_:) + 60 (Create.swift:60)
30  RxSwift                        0x10644f668 AnonymousObservable.run<A>(_:cancel:) + 76 (Create.swift:76)
31  RxSwift                        0x10645e448 Producer.subscribe<A>(_:) + 18 (Producer.swift:18)
32  RxSwift                        0x10642c3e4 RetryWhenSequenceSink.subscribeToNext(_:) + 155 (RetryWhen.swift:155)
33  RxSwift                        0x106449b20 TailRecursiveSink.moveNextCommand() + 130 (TailRecursiveSink.swift:130)
34  RxSwift                        0x106449f78 protocol witness for InvocableWithValueType.invoke(_:) in conformance TailRecursiveSink<A, B> + 4333363064 (<compiler-generated>:4333363064)
35  RxSwift                        0x10641b6e4 InvocableScheduledItem.invoke() + 20 (InvocableScheduledItem.swift:20)
36  RxSwift                        0x10644a908 AsyncLock.invoke(_:) + 75 (AsyncLock.swift:75)
37  RxSwift                        0x106448f84 TailRecursiveSink.schedule(_:) + 56 (TailRecursiveSink.swift:56)
38  RxSwift                        0x106448e64 TailRecursiveSink.run(_:) + 42 (TailRecursiveSink.swift:42)
39  RxSwift                        0x10642c610 RetryWhenSequenceSink.run(_:) + 161 (RetryWhen.swift:161)
40  RxSwift                        0x10642cacc RetryWhenSequence.run<A>(_:cancel:) + 179 (RetryWhen.swift:179)
41  RxSwift                        0x10645e448 Producer.subscribe<A>(_:) + 18 (Producer.swift:18)
42  RxSwift                        0x106440258 ObservableType.subscribe(_:) + 25 (ObservableType+Extensions.swift:25)
43  RxSwift                        0x106482ce4 PrimitiveSequenceType<>.subscribe(_:) + 61 (Single.swift:61)
44  RxSwift                        0x10648320c PrimitiveSequenceType<>.subscribe(onSuccess:onError:) + 90 (Single.swift:90)
45  App                         0x104da85fc closure #2 in IntroController.fetchMetaAndUser() + 165 (IntroController.swift:165)
46  RxSwift                        0x106485384 closure #2 in ObservableType.do(onNext:afterNext:onError:afterError:onCompleted:afterCompleted:onSubscribe:onSubscribed:onDispose:) + 40 (Do.swift:40)
47  RxSwift                        0x106485100 partial apply for closure #1 in ObservableType.do(onNext:afterNext:onError:afterError:onCompleted:afterCompleted:onSubscribe:onSubscribed:onDispose:) + 4333605120 (<compiler-generated>:4333605120)
48  RxSwift                        0x106485670 DoSink.on(_:) + 66 (Do.swift:66)
49  RxSwift                        0x1064858b0 protocol witness for ObserverType.on(_:) in conformance DoSink<A> + 4333607088 (<compiler-generated>:4333607088)
50  RxSwift                        0x106458f88 Sink.forwardOn(_:) + 35 (Sink.swift:35)
51  RxSwift                        0x10642bcd0 RetryWhenSequenceSinkIter.on(_:) + 85 (RetryWhen.swift:85)
52  RxSwift                        0x10642c070 protocol witness for ObserverType.on(_:) in conformance RetryWhenSequenceSinkIter<A, B, C, D> + 4333240432 (<compiler-generated>:4333240432)
53  RxSwift                        0x1064b65e8 closure #1 in ObserveOnSerialDispatchQueueSink.init(scheduler:observer:cancel:) + 186 (ObserveOn.swift:186)
54  RxSwift                        0x1064b6d50 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed ObserveOnSerialDispatchQueueSink<A>, @in_guaranteed Event<A.Element>) -> (@out Disposable) + 4333808976 (<compiler-generated>:4333808976)
55  RxSwift                        0x1064354bc MainScheduler.scheduleInternal<A>(_:action:) + 63 (MainScheduler.swift:63)
56  RxSwift                        0x1064b68f4 ObserveOnSerialDispatchQueueSink.onCore(_:) + 195 (ObserveOn.swift:195)
57  RxSwift                        0x106442358 ObserverBase.on(_:) + 16 (ObserverBase.swift:16)
58  RxSwift                        0x106442614 protocol witness for ObserverType.on(_:) in conformance ObserverBase<A> + 4333331988 (<compiler-generated>:4333331988)
59  RxSwift                        0x106458f88 Sink.forwardOn(_:) + 35 (Sink.swift:35)
60  RxSwift                        0x10647f798 SubscribeOnSink.on(_:) + 46 (SubscribeOn.swift:46)
61  RxSwift                        0x10647fe18 protocol witness for ObserverType.on(_:) in conformance SubscribeOnSink<A, B> + 4333583896 (<compiler-generated>:4333583896)
62  RxSwift                        0x106458f88 Sink.forwardOn(_:) + 35 (Sink.swift:35)
63  RxSwift                        0x1064583c8 ZipSink.next(_:) + 60 (Zip.swift:60)
64  RxSwift                        0x106458ad4 ZipObserver._synchronized_on(_:) + 128 (Zip.swift:128)
65  RxSwift                        0x106454088 SynchronizedOnType.synchronizedOn(_:) + 15 (<compiler-generated>:15)
66  RxSwift                        0x10645887c ZipObserver.on(_:) + 110 (Zip.swift:110)
67  RxSwift                        0x106458b94 protocol witness for ObserverType.on(_:) in conformance ZipObserver<A> + 4333423508 (<compiler-generated>:4333423508)
68  RxSwift                        0x106458f88 Sink.forwardOn(_:) + 35 (Sink.swift:35)
69  RxSwift                        0x1064a2b50 DeferredSink.on(_:) + 49 (Deferred.swift:49)
70  RxSwift                        0x1064a2cc4 protocol witness for ObserverType.on(_:) in conformance DeferredSink<A, B> + 4333726916 (<compiler-generated>:4333726916)
71  RxSwift                        0x106458f88 Sink.forwardOn(_:) + 35 (Sink.swift:35)
72  RxSwift                        0x10644f330 AnonymousObservableSink.on(_:) + 50 (Create.swift:50)
73  RxSwift                        0x10644f544 protocol witness for ObserverType.on(_:) in conformance AnonymousObservableSink<A> + 4333385028 (<compiler-generated>:4333385028)
74  RxSwift                        0x1064b0e64 partial apply + 4333784676 (<compiler-generated>:4333784676)
75  RxSwift                        0x10642e454 AnyObserver.on(_:) + 36 (AnyObserver.swift:36)
76  RxSwift                        0x106482b60 closure #1 in closure #1 in static PrimitiveSequenceType<>.create(subscribe:) + 42 (Single.swift:42)
77  App                         0x104efca68 closure #1 in closure #1 in static ProfileMeta.getMeta(gender:) + 25 (ProfileMeta.swift:25)
78  RxSwift                        0x1064829c0 partial apply for closure #1 in static PrimitiveSequenceType<>.create(subscribe:) + 39 (Single.swift:39)
79  RxSwift                        0x10644f444 AnonymousObservableSink.run(_:) + 60 (Create.swift:60)
80  RxSwift                        0x10644f668 AnonymousObservable.run<A>(_:cancel:) + 76 (Create.swift:76)
81  RxSwift                        0x10645e448 Producer.subscribe<A>(_:) + 18 (Producer.swift:18)
82  RxSwift                        0x1064b11b0 protocol witness for ObservableType.subscribe<A>(_:) in conformance Observable<A> + 4333785520 (<compiler-generated>:4333785520)
83  RxSwift                        0x1064a2aa4 DeferredSink.run() + 37 (Deferred.swift:37)
84  RxSwift                        0x1064a2ddc Deferred.run<A>(_:cancel:) + 73 (Deferred.swift:73)
85  RxSwift                        0x10645e448 Producer.subscribe<A>(_:) + 18 (Producer.swift:18)
86  RxSwift                        0x10646deb8 ZipSink3_.run() + 196 (Zip+arity.swift:196)
87  RxSwift                        0x10646e614 Zip3.run<A>(_:cancel:) + 230 (Zip+arity.swift:230)
88  RxSwift                        0x10645ea58 closure #1 in Producer.subscribe<A>(_:) + 26 (Producer.swift:26)
89  RxSwift                        0x10645eb28 partial apply for thunk for @escaping @callee_guaranteed () -> (@out Disposable) + 4333447976 (<compiler-generated>:4333447976)
90  RxSwift                        0x106455554 specialized CurrentThreadScheduler.schedule<A>(_:action:) + 101 (CurrentThreadScheduler.swift:101)
91  RxSwift                        0x10645e5b8 Producer.subscribe<A>(_:) + 24 (Producer.swift:24)
92  RxSwift                        0x1064b11b0 protocol witness for ObservableType.subscribe<A>(_:) in conformance Observable<A> + 4333785520 (<compiler-generated>:4333785520)
93  RxSwift                        0x10647fb94 closure #1 in SubscribeOnSink.run() + 59 (SubscribeOn.swift:59)
94  RxSwift                        0x10645e5f8 thunk for @escaping @callee_guaranteed () -> (@out Disposable) + 4333446648 (<compiler-generated>:4333446648)
95  RxSwift                        0x1064291b4 closure #1 in DispatchQueueConfiguration.schedule<A>(_:action:) + 27 (DispatchQueueConfiguration.swift:27)
96  RxSwift                        0x106429204 thunk for @escaping @callee_guaranteed () -> () + 4333228548 (<compiler-generated>:4333228548)
97  libdispatch.dylib              0x1b1026610 _dispatch_call_block_and_release + 24
98  libdispatch.dylib              0x1b1027184 _dispatch_client_callout + 16
99  libdispatch.dylib              0x1b100a34c _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 996
100 CoreFoundation                 0x1b12d73a8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
101 CoreFoundation                 0x1b12d239c __CFRunLoopRun + 2004
102 CoreFoundation                 0x1b12d18a0 CFRunLoopRunSpecific + 464
103 GraphicsServices               0x1bb229328 GSEventRunModal + 104
104 UIKitCore                      0x1b53c2740 UIApplicationMain + 1936
105 App                         0x104b34c4c main + 15 (SignUpInputTextViewController.swift:15)
106 libdyld.dylib                  0x1b115c360 start + 4

Realm Object Server version: ?

Xcode version: 11.2

iOS/OSX version: iOS 11, 12, 13

Dependency manager + version: Carthage 0.34.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 39 (7 by maintainers)

Most upvoted comments

I started having this too after transition from 4.4.1 -> 5.0.2

Any updates on it?

We get the same on 10.1.4

Crashed: BaseFileSyncManager.processQueue.CC283DBC-BAFF-4CB2-9BA8-420189EA81C8
0  Xxxxxx                         0x101b322a8 _hidden#113_ + 204 (__hidden#171_:204)
1  Xxxxxx                         0x1019cf0a4 _hidden#645_ + 568 (__hidden#748_:568)
2  Xxxxxx                         0x1019de6ec _hidden#1648_ + 135 (__hidden#802_:135)
3  Xxxxxx                         0x1019e3388 _hidden#1887_ + 966 (__hidden#1414_:966)
4  Xxxxxx                         0x1019df6a4 realm::_impl::transaction::advance(std::__1::shared_ptr<realm::Transaction> const&, realm::BindingContext*, realm::_impl::NotifierPackage&) + 3831 (__hidden#20_:3831)
5  Xxxxxx                         0x1019d7058 realm::_impl::RealmCoordinator::advance_to_latest(realm::Realm&) + 3826 (__hidden#20_:3826)
6  Xxxxxx                         0x101a19cd8 realm::Realm::do_refresh() + 819 (__hidden#4118_:819)
7  Xxxxxx                         0x101ad7b88 _hidden#11049_ + 759 (__hidden#11192_:759)
8  Xxxxxx                         0x101b11b54 Realm.refresh() + 782 (__hidden#3095_:782)
9  Xxxxxx                         0x101351560 specialized RealmDatabaseManager.object<A>(_:iid:) + 119 (RealmDatabaseManager.swift:119)
10 Xxxxxx                         0x101351b24 RealmDatabaseManager.object<A>(id:) + 128 (RealmDatabaseManager.swift:128)
11 Xxxxxx                         0x10135376c protocol witness for DatabaseManager.object<A>(id:) in conformance RealmDatabaseManager + 4337006444 (<compiler-generated>:4337006444)
12 Xxxxxx                         0x1012c638c BaseFileSyncManager.getFromLocalStorages(trackId:forNotification:) + 380 (BaseFileSyncManager.swift:380)
13 Xxxxxx                         0x1012c5de0 closure #1 in BaseFileSyncManager.handleStreamRequest(trackIds:) + 235 (BaseFileSyncManager.swift:235)
14 Xxxxxx                         0x1012c2b30 BaseFileSyncManager.handleStreamRequest(trackIds:) + 4336413488 (<compiler-generated>:4336413488)
15 Xxxxxx                         0x1012c296c closure #1 in BaseFileSyncManager.requestFile(_:) + 88 (BaseFileSyncManager.swift:88)
16 Xxxxxx                         0x100eb2db0 thunk for @escaping @callee_guaranteed () -> () + 4332154288 (<compiler-generated>:4332154288)
17 libdispatch.dylib              0x18e175298 _dispatch_call_block_and_release + 24
18 libdispatch.dylib              0x18e176280 _dispatch_client_callout + 16
19 libdispatch.dylib              0x18e1524fc _dispatch_lane_serial_drain$VARIANT$armv81 + 568
20 libdispatch.dylib              0x18e15301c _dispatch_lane_invoke$VARIANT$armv81 + 456
21 libdispatch.dylib              0x18e15c808 _dispatch_workloop_worker_thread + 692
22 libsystem_pthread.dylib        0x1d3d905a4 _pthread_wqthread + 272
23 libsystem_pthread.dylib        0x1d3d93874 start_wqthread + 8

@igrechuhin it appears the issue you are seeing is different than the initial reported issue. If you are still encountering the issue, please open another ticket so that we can investigate further.

We can not reproduce it, but it happens VERY frequently at our users. More than 6k crashes per day. Is there any logging I can add to the app to help investigate and fix this issue?

using 5.4.7

Crashed: com.slatch.dataQueue 0 Realm 0x10555fe5c realm::Array::init_from_mem(realm::MemRef) + 20 1 Realm 0x1055f547c realm::Group::attach(unsigned long, bool, bool) + 196 2 Realm 0x1055fcf68 realm::Group::advance_transact(unsigned long, unsigned long, realm::_impl::NoCopyInputStream&, bool) + 276 3 Realm 0x1054d65d0 void realm::Transaction::rollback_and_continue_as_readrealm::_impl::NullInstructionObserver(realm::_impl::NullInstructionObserver*) + 3831 (memory:3831) 4 Realm 0x1054d525c realm::_impl::transaction::cancel(realm::Transaction&, realm::BindingContext*) + 555 (vector:555) 5 Realm 0x1054b50fc realm::Realm::cancel_transaction() + 2608 (memory:2608) 6 Realm 0x1054848f8 -[RLMRealm cancelWriteTransaction] + 735 (RLMRealm.mm:735) 7 Realm 0x105484b78 -[RLMRealm dealloc] + 809 (RLMRealm.mm:809) 8 libobjc.A.dylib 0x1887db38c (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 676 9 libdispatch.dylib 0x18902a464 _dispatch_last_resort_autorelease_pool_pop + 40 10 libdispatch.dylib 0x188fd2778 _dispatch_lane_invoke$VARIANT$mp + 528 11 libdispatch.dylib 0x188fdaeb8 _dispatch_workloop_worker_thread + 600 12 libsystem_pthread.dylib 0x18920d0dc _pthread_wqthread + 312 13 libsystem_pthread.dylib 0x18920fcec start_wqthread + 4

still happens

Btw, I am only getting these type of crashes when using frozen objects. I have a UITableView powered by a datasource full of frozen objects. In a background thread, I have a “synchronizer” that every X minutes pulls new data from the backend, does some “merge” logic between the pulled data(unmanaged objects) and the locally stored data(managed but not frozen) and then tells the datasource to refresh with those local objects(freezing them first).

The crash was happening, in my scenario, when the synchronizer was doing all the merging logic between unmanaged objects and managed objects while the datasource was holding references to frozen objects. If the datasource, instead of holding references to frozen objects hold references to normal managed objects, I never get the crash doing the merging.

I really want to make usage of the frozen objects, its a good case scenario for my datasource, but at this point it is just impossible without getting all sort of different errors and crashes.