realm-swift icon indicating copy to clipboard operation
realm-swift copied to clipboard

Realm please_report_this_issue_in_github_realm_realm_core + 12

Open mmar001 opened this issue 1 year ago • 7 comments

How frequently does the bug occur?

Sometimes

Description

We have a crash in live app when access to Realm Database in this function:

private func getDatabase() -> Realm? {
        return queue.sync {
            do {
                fixRealmBackgroundCrash(config: appConf)
                let db = try Realm(configuration: appConf)
                
                return db
            } catch {
                logError(err: error)

                let databaseConfiguration = Realm.Configuration(
                    schemaVersion: DatabaseManager.currentSchemaVersion,
                    migrationBlock: DatabaseManager.migrationBlock
                )
                fixRealmBackgroundCrash(config: databaseConfiguration)
                let db = try? Realm(configuration: databaseConfiguration)
                
          
                return db
            }
        }
    }

func fixRealmBackgroundCrash(config: Realm.Configuration) {
        // Source: https://github.com/realm/realm-cocoa/issues/7112#issuecomment-778218878
        let folderPath = config.fileURL!.deletingLastPathComponent().path
        do {
            let attributes = try FileManager.default.attributesOfItem(atPath: folderPath)
            let protectionType = attributes[.protectionKey] as? FileProtectionType
            if protectionType != .some(FileProtectionType.none) {
                try FileManager.default.setAttributes([.protectionKey: FileProtectionType.none], ofItemAtPath: folderPath)
            }
        } catch {
            log("Unable to set protection attributes for realm folder: \(error)")
        }
    }

Stacktrace & log output

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib        	0x00000001bb916bbc __pthread_kill + 8
1   libsystem_pthread.dylib       	0x00000001dc3a4854 pthread_kill + 208 (pthread.c:1668)
2   libsystem_c.dylib             	0x000000018b7820b0 __abort + 124 (abort.c:155)
3   libsystem_c.dylib             	0x000000018b72d6b8 abort + 136 (abort.c:126)
4   Realm                         	0x0000000106bf3604 please_report_this_issue_in_github_realm_realm_core + 12
5   Realm                         	0x0000000106bf3904 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 328
6   Realm                         	0x0000000106bf3c68 realm::util::terminate_with_info(char const*, char const*, long, char const*, std::initializer_list<realm::util::Printable>&&) + 388
7   Realm                         	0x0000000106ae0aa0 void realm::util::terminate_with_info<unsigned long&, unsigned long&>(char const*, int, char const*, char const*, unsigned long&, unsigned long&) + 68
8   Realm                         	0x0000000106bd7c30 realm::util::EncryptedFileMapping::read_barrier(void const*, unsigned long, unsigned long (*)(char const*)) + 508
9   Realm                         	0x0000000106936634 realm::util::do_encryption_read_barrier(void const*, unsigned long, unsigned long (*)(char const*), realm::util::EncryptedFileMapping*) + 84 (file_mapper.hpp:132)
10  Realm                         	0x0000000106a96898 realm::Cluster::init(realm::MemRef) + 332
11  Realm                         	0x0000000106aa5530 realm::ClusterTree::create_root_from_parent(realm::ArrayParent*, unsigned long) + 508
12  Realm                         	0x0000000106aa5884 realm::ClusterTree::init_from_parent() + 36
13  Realm                         	0x0000000106babdcc realm::Table::init(unsigned long, realm::ArrayParent*, unsigned long, bool, bool) + 204
14  Realm                         	0x0000000106accd80 realm::Group::create_table_accessor(unsigned long) + 804
15  Realm                         	0x0000000106acca00 realm::Group::do_get_table(unsigned long) + 96
16  Realm                         	0x0000000106cdfa70 realm::ObjectSchema::ObjectSchema(realm::Group const&, realm::StringData, realm::TableKey) + 284
17  Realm                         	0x0000000106ce865c realm::ObjectStore::schema_from_group(realm::Group const&) + 120
18  Realm                         	0x0000000106d449c8 realm::Realm::read_schema_from_group_if_needed() + 132
19  Realm                         	0x0000000106d446d4 realm::Realm::Realm(realm::Realm::Config, realm::util::Optional<realm::VersionID>, std::__1::shared_ptr<realm::_impl::RealmCoordinator>, realm::Realm::MakeSharedTag) + 424
20  Realm                         	0x0000000106cb5fec realm::Realm::make_shared_realm(realm::Realm::Config, realm::util::Optional<realm::VersionID>, std::__1::shared_ptr<realm::_impl::RealmCoordinator>) + 180
21  Realm                         	0x0000000106cb5178 realm::_impl::RealmCoordinator::do_get_realm(realm::Realm::Config, std::__1::shared_ptr<realm::Realm>&, realm::util::Optional<realm::VersionID>, realm::util::CheckedUniqueLock&) + 436
22  Realm                         	0x0000000106cb4e30 realm::_impl::RealmCoordinator::get_realm(realm::Realm::Config, realm::util::Optional<realm::VersionID>) + 400
23  Realm                         	0x0000000106d455ec realm::Realm::get_shared_realm(realm::Realm::Config) + 120
24  Realm                         	0x0000000106a4646c +[RLMRealm realmWithConfiguration:queue:error:] + 1152 (RLMRealm.mm:496)
25  RealmSwift                    	0x00000001062f6d24 $sSo8RLMRealmC13configuration5queueABSo0A13ConfigurationC_So012OS_dispatch_C0CSgtKcfCTOTf4ggn_n + 40 (<compiler-generated>:0)
26  RealmSwift                    	0x00000001062f6d24 $sSo8RLMRealmC13configuration5queueABSo0A13ConfigurationC_So012OS_dispatch_C0CSgtKcfCTO + 40 (<compiler-generated>:0)
27  RealmSwift                    	0x00000001062f6d24 Realm.init(configuration:queue:) + 92 (Realm.swift:92)
28  IT                            	0x000000010321a4d0 closure #1 in DatabaseManager.getDatabase() + 524
...
31  libswiftDispatch.dylib        	0x000000019960283c partial apply for thunk for @callee_guaranteed () -> (@out A, @error @owned Error) + 20 (<compiler-generated>:0)
32  libswiftDispatch.dylib        	0x0000000199602854 thunk for @callee_guaranteed () -> (@out A, @error @owned Error)partial apply + 12
33  libswiftDispatch.dylib        	0x00000001996039ac closure #1 in closure #1 in OS_dispatch_queue._syncHelper<A>(fn:execute:rescue:) + 120 (Queue.swift:319)
34  libswiftDispatch.dylib        	0x0000000199603a74 partial apply for thunk for @callee_guaranteed () -> () + 20 (<compiler-generated>:0)
35  libswiftDispatch.dylib        	0x0000000199603478 thunk for @escaping @callee_guaranteed () -> () + 20 (<compiler-generated>:0)
36  libdispatch.dylib             	0x0000000180d04094 _dispatch_client_callout + 16 (object.m:560)
37  libdispatch.dylib             	0x0000000180cb1964 _dispatch_lane_barrier_sync_invoke_and_complete + 52 (queue.c:1028)
38  libswiftDispatch.dylib        	0x0000000199602e18 implicit closure #2 in implicit closure #1 in OS_dispatch_queue.sync<A>(execute:) + 152
39  libswiftDispatch.dylib        	0x00000001996020ac partial apply for implicit closure #2 in implicit closure #1 in OS_dispatch_queue.sync<A>(execute:) + 40 (<compiler-generated>:0)
40  libswiftDispatch.dylib        	0x0000000199602bb0 OS_dispatch_queue._syncHelper<A>(fn:execute:rescue:) + 256 (Queue.swift:317)
41  libswiftDispatch.dylib        	0x0000000199602140 OS_dispatch_queue.sync<A>(execute:) + 140 (Queue.swift:369)
....
50  libdispatch.dylib             	0x0000000180d04094 _dispatch_client_callout + 16 (object.m:560)
51  libdispatch.dylib             	0x0000000180ca5acc _dispatch_once_callout + 28 (once.c:52)
...
57  UIKitCore                     	0x00000001835f35d0 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 336 (UIApplication.m:2334)
58  UIKitCore                     	0x00000001837c7da4 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3508 (UIApplication.m:2754)
59  UIKitCore                     	0x00000001837b14c8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1176 (UIApplication.m:4491)
60  UIKitCore                     	0x000000018361f2e0 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 148 (_UISceneLifecycleMultiplexer.m:450)
61  UIKitCore                     	0x0000000183486004 _UIScenePerformActionsWithLifecycleActionMask + 96 (_UISceneLifecycleState.m:109)
62  UIKitCore                     	0x00000001835a8a38 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 188 (_UISceneLifecycleMultiplexer.m:563)
63  UIKitCore                     	0x00000001836be094 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 368 (_UISceneLifecycleMultiplexer.m:515)
64  UIKitCore                     	0x00000001838e6440 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 744 (_UISceneLifecycleMultiplexer.m:562)
65  UIKitCore                     	0x0000000183876180 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 336 (_UISceneLifecycleMultiplexer.m:468)
66  UIKitCore                     	0x0000000183486d50 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block... + 188 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:73)
67  UIKitCore                     	0x0000000183542940 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 812 (BSAnimationSettings+UIKit.m:50)
68  UIKitCore                     	0x0000000183488ae0 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 248 (_UISceneSettingsDiffAction.m:23)
69  UIKitCore                     	0x000000018356d190 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 356 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:58)
70  UIKitCore                     	0x00000001839c2f44 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.578 + 772 (UIScene.m:1825)
71  UIKitCore                     	0x00000001834b6788 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 248 (UIScene.m:1526)
72  UIKitCore                     	0x00000001834f8528 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 264 (UIScene.m:1792)
73  UIKitCore                     	0x0000000183623d48 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 560 (UIApplication.m:3955)
74  UIKitCore                     	0x000000018356b5ac -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360 (UIApplicationSceneClientAgent.m:45)
75  FrontBoardServices            	0x00000001921c3c50 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 412 (FBSScene.m:439)
76  FrontBoardServices            	0x00000001921e5f98 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.180 + 100 (FBSWorkspaceScenesClient.m:384)
77  FrontBoardServices            	0x00000001921a6bdc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232 (FBSWorkspace.m:352)
78  FrontBoardServices            	0x00000001921a7fd4 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 312 (FBSWorkspaceScenesClient.m:383)
79  libdispatch.dylib             	0x0000000180d04094 _dispatch_client_callout + 16 (object.m:560)
80  libdispatch.dylib             	0x0000000180ca7150 _dispatch_block_invoke_direct$VARIANT$mp + 220 (queue.c:501)
81  FrontBoardServices            	0x00000001921a82ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40 (FBSSerialQueue.m:157)
82  FrontBoardServices            	0x00000001921a77c0 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176 (FBSSerialQueue.m:181)
83  FrontBoardServices            	0x00000001921ab960 -[FBSSerialQueue _performNextFromRunLoopSource] + 24 (FBSSerialQueue.m:194)
84  CoreFoundation                	0x00000001810644fc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1972)
85  CoreFoundation                	0x000000018107462c __CFRunLoopDoSource0 + 204 (CFRunLoop.c:2016)
86  CoreFoundation                	0x0000000180fb6834 __CFRunLoopDoSources0 + 256 (CFRunLoop.c:2053)
87  CoreFoundation                	0x0000000180fbbf08 __CFRunLoopRun + 768 (CFRunLoop.c:2951)
88  CoreFoundation                	0x0000000180fcf250 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3268)
89  GraphicsServices              	0x00000001a1b02988 GSEventRunModal + 160 (GSEvent.c:2200)
90  UIKitCore                     	0x00000001837cfa94 -[UIApplication _run] + 1080 (UIApplication.m:3511)
91  UIKitCore                     	0x0000000183568fd4 UIApplicationMain + 336 (UIApplication.m:5064)
93  dyld                          	0x00000001049b44d0 start + 444 (dyldMain.cpp:879)

Can you reproduce the bug?

Not yet

Reproduction Steps

No response

Version

10.28.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

Yes, using encryption

Platform OS and version(s)

iOS 15.4.1 ~ 15.6.1 - multiple iPhone

Build environment

No response

mmar001 avatar Sep 13 '22 16:09 mmar001

Hi @mmar001, Are you able to reproduce this issue?, this happens all the time or something that happens randomly?, Do you know if this error started in a specific version of realm. This seems related to this https://github.com/realm/realm-swift/issues/6308, but a fix for this issue was merged a long time ago. This probably been caused by the file permission not been set to none before trying to open the realm. I'm a little bit confused by the code below, do you have two realm with different configuration? What is the difference between databaseConfiguration and appConfig

dianaafanador3 avatar Sep 14 '22 14:09 dianaafanador3

appConfig is the configuration of the encrypted DB, if it cannot be opened then it use databaseConfiguration (not encrypted). We cannot reproduce this issue it is reported in crashlytics only on live app.

mmar001 avatar Sep 14 '22 15:09 mmar001

Hello, we are also seeing a lot of similar crashes on our production apps, the stack traces are not always the same, but they all always end up in terminate function. Do you guys have any hint? In our case these crashes started happening when we updated our RealmSwift from version 3.18 to 10.28.0.

rserentill avatar Sep 20 '22 16:09 rserentill

Hi @rserentill do you have any stack traces, terminate function is our internal function when there is an undefined behaviour that we detect in our side, but this could mean many things which could be related to this issue error or not.

dianaafanador3 avatar Sep 20 '22 16:09 dianaafanador3

Hi @dianaafanador3! Thank you for your answer, yes I do, I'm pasting some of them here. We are accessing Realm from different threads, but all Realm instances are always created and accessed from the same thread.

Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x7b38 __pthread_kill + 8
1  libsystem_pthread.dylib        0x73bc pthread_kill + 268
2  libsystem_c.dylib              0x20524 abort + 168
3  myapp                          0x9fedd4 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 128 (terminate.cpp:128)
4  myapp                          0x9ff114 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 123 (terminate.cpp:123)
5  myapp                          0x9fee90 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 133 (terminate.cpp:133)
6  myapp                          0x597208 void realm::util::terminate_with_info<char const&, unsigned long&>(char const*, int, char const*, char const*, char const&, unsigned long&) + 51 (terminate.hpp:51)
7  myapp                          0x7378c0 realm::Array::set_as_ref(unsigned long, unsigned long) + 389 (array.cpp:389)
8  myapp                          0x7d6050 realm::Obj& realm::Obj::set<bool>(realm::ColKey, bool, bool) + 159 (node.hpp:159)
9  myapp                          0x53caa4 void (anonymous namespace)::kvoSetValue<bool, bool>(RLMObjectBase*, unsigned long, bool) + 405 (RLMAccessor.mm:405)
10 myapp                          0x33976c closure #1 in IssueDownloadMetadataDatabaseRepositoryRealm.markAsCompleted(_:) + 260 (<compiler-generated>:260)
Crashed: com.apple.NSURLSession-delegate
0  libsystem_kernel.dylib         0x7b38 __pthread_kill + 8
1  libsystem_pthread.dylib        0x73bc pthread_kill + 268
2  libsystem_c.dylib              0x20524 abort + 168
3  myapp                          0x9fedd4 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 128 (terminate.cpp:128)
4  myapp                          0x9ff114 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 123 (terminate.cpp:123)
5  myapp                          0x9fee90 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 133 (terminate.cpp:133)
6  myapp                          0x5bcb50 std::__1::__vector_base<double, std::__1::allocator<double> >::__throw_length_error() const + 396 (vector:396)
7  myapp                          0x7d5a3c realm::Node::calc_item_count(unsigned long, unsigned long) const + 61 (node.cpp:61)
8  myapp                          0x7d5a90 realm::Node::alloc(unsigned long, unsigned long) + 76 (node.cpp:76)
9  myapp                          0x7376ac realm::Array::alloc(unsigned long, unsigned long) + 207 (array.hpp:207)
10 myapp                          0x737b74 realm::Array::insert(unsigned long, long long) + 447 (array.cpp:447)
11 myapp                          0x75a170 void realm::Cluster::do_insert_row<realm::ArrayInteger>(unsigned long, realm::ColKey, realm::Mixed, bool) + 275 (cluster.cpp:275)
12 myapp                          0x759f18 realm::util::FunctionRef<bool (realm::ColKey)>::FunctionRef<realm::Cluster::insert_row(unsigned long, realm::ObjKey, realm::FieldValues const&)::$_1&>(realm::Cluster::insert_row(unsigned long, realm::ObjKey, realm::FieldValues const&)::$_1&)::'lambda'(void*, realm::ColKey)::__invoke(void*, realm::ColKey) + 386 (cluster.cpp:386)
13 myapp                          0x9cb26c realm::TableClusterTree::for_each_and_every_column(realm::util::FunctionRef<bool (realm::ColKey)>) const + 68 (table.hpp:68)
14 myapp                          0x755044 realm::Cluster::insert_row(unsigned long, realm::ObjKey, realm::FieldValues const&) + 440 (cluster.cpp:440)
15 myapp                          0x756ce0 realm::Cluster::insert(realm::ObjKey, realm::FieldValues const&, realm::ClusterNode::State&) + 703 (cluster.cpp:703)
16 myapp                          0x765a18 realm::ClusterTree::insert_fast(realm::ObjKey, realm::FieldValues const&, realm::ClusterNode::State&) + 882 (cluster_tree.cpp:882)
17 myapp                          0x765b8c realm::ClusterTree::insert(realm::ObjKey, realm::FieldValues const&) + 900 (cluster_tree.cpp:900)
18 myapp                          0x9cae14 realm::TableClusterTree::insert(realm::ObjKey, realm::FieldValues const&) + 47 (table_cluster_tree.cpp:47)
19 myapp                          0x9bf8a8 realm::Table::create_object_with_primary_key(realm::Mixed const&, realm::FieldValues&&, realm::Table::UpdateMode, bool*) + 3067 (table.cpp:3067)
20 myapp                          0x54b95c realm::Table::create_object_with_primary_key(realm::Mixed const&, bool*) + 485 (vector:485)
21 myapp                          0x540dd4 realm::Object realm::Object::create<objc_object* __strong, RLMAccessorContext>(RLMAccessorContext&, std::__1::shared_ptr<realm::Realm> const&, realm::ObjectSchema const&, objc_object* __strong, realm::CreatePolicy, realm::ObjKey, realm::Obj*) + 305 (object_accessor.hpp:305)
22 myapp                          0x540774 RLMAccessorContext::createObject(objc_object*, realm::CreatePolicy, bool, realm::ObjKey) + 1102 (RLMAccessor.mm:1102)
23 myapp                          0x595d5c RLMAddObjectToRealm + 120 (RLMObjectStore.mm:120)
24 myapp                          0x33651c closure #1 in IssueDatabaseRepositoryRealm.createOrUpdate(_:) + 61 (IssueDatabaseRepositoryRealm.swift:61)
25 myapp                          0x340f58 thunk for @callee_guaranteed () -> (@error @owned Error) + 20 (<compiler-generated>:20)
26 myapp                          0x3388a4 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) + 16 (<compiler-generated>:16)
27 myapp                          0x6facc8 Realm.write<A>(withoutNotifying:_:) + 258 (Realm.swift:258)
28 myapp                          0x335c40 IssueDatabaseRepositoryRealm.createOrUpdate(_:) + 552 (<compiler-generated>:552)
Crashed: com.apple.NSURLSession-delegate
0  libsystem_kernel.dylib         0x7b38 __pthread_kill + 8
1  libsystem_pthread.dylib        0x73bc pthread_kill + 268
2  libsystem_c.dylib              0x20524 abort + 168
3  myapp                          0x7b0ab4 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 128 (terminate.cpp:128)
4  myapp                          0x7b0df4 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 123 (terminate.cpp:123)
5  myapp                          0x7b0b70 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 133 (terminate.cpp:133)
6  myapp                          0x5911d0 realm::StringData realm::Obj::_get<realm::StringData>(realm::ColKey::Idx) const + 156 (array_string_short.hpp:156)
7  myapp                          0x5926b0 realm::Obj::get_any(realm::ColKey) const + 395 (mixed.hpp:395)
8  myapp                          0x550d88 long long realm::IndexArray::index_string<(realm::IndexMethod)0>(realm::Mixed, realm::InternalFindResult&, realm::ClusterColumn const&) const + 215 (mixed.hpp:215)
9  myapp                          0x5507d4 realm::IndexArray::index_string_find_first(realm::Mixed, realm::ClusterColumn const&) const + 585 (index_string.cpp:585)
10 myapp                          0x76f400 realm::ObjKey realm::Table::find_first<realm::StringData>(realm::ColKey, realm::StringData) const + 464 (index_string.hpp:464)
11 myapp                          0x6d6340 realm::StringNode<realm::Equal>::_search_index_init() + 346 (query_engine.cpp:346)
12 myapp                          0x6a8c04 realm::Query::init() const + 459 (vector:459)
13 myapp                          0x6a8c8c realm::Query::do_find_all(realm::TableView&, unsigned long) const + 680 (vector:680)
14 myapp                          0x782c0c realm::TableView::do_sync() + 603 (table_view.cpp:603)
15 myapp                          0x6a8f80 realm::Query::find_all(unsigned long) + 1528 (query.cpp:1528)
16 myapp                          0x5f5338 realm::Results::ensure_up_to_date(realm::Results::EvaluateMode) + 275 (results.cpp:275)
17 myapp                          0x5f4d50 realm::util::Optional<realm::Obj> realm::Results::try_get<realm::Obj>(unsigned long) + 368 (results.cpp:368)
18 myapp                          0x5f5058 realm::util::Optional<realm::Obj> realm::Results::first<realm::Obj>() + 139 (__mutex_base:139)
19 myapp                          0x423a3c RLMAccessorContext realm::Results::dispatch<auto realm::Results::first<RLMAccessorContext>(RLMAccessorContext&)::'lambda'(RLMAccessorContext&)>(RLMAccessorContext&) const + 404 (optional.hpp:404)
20 myapp                          0x42388c auto realm::Results::first<RLMAccessorContext>(RLMAccessorContext&) + 420 (results.hpp:420)
21 myapp                          0x421668 -[RLMResults firstObject] + 248 (RLMResults.mm:248)
22 myapp                          0x47c7cc RealmCollectionImpl.first.getter + 72
23 myapp                          0x47fa74 protocol witness for RealmCollection.first.getter in conformance Results<A> + 80 (<compiler-generated>:80)
24 myapp                          0x81b69c IssueDatabaseRepositoryRealm.createOrUpdate(_:) + 27 (IssueDatabaseRepositoryRealm.swift:27)
Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x7b38 __pthread_kill + 8
1  libsystem_pthread.dylib        0x73bc pthread_kill + 268
2  libsystem_c.dylib              0x20524 abort + 168
3  myapp                          0x9fedd4 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 128 (terminate.cpp:128)
4  myapp                          0x9ff114 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 123 (terminate.cpp:123)
5  myapp                          0x9fee90 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 133 (terminate.cpp:133)
6  myapp                          0x76dea8 realm::DB::do_end_write() + 2291 (db.cpp:2291)
7  myapp                          0x77026c realm::Transaction::rollback() + 2790 (db.cpp:2790)
8  myapp                          0x76cd18 realm::Transaction::close() + 2693 (db.cpp:2693)
9  myapp                          0x777c00 std::__1::__shared_ptr_pointer<realm::Transaction*, (anonymous namespace)::$_8, std::__1::allocator<realm::Transaction> >::__on_zero_shared() + 393 (db.cpp:393)
10 myapp                          0x54f3c8 std::__1::shared_ptr<realm::app::App>::~shared_ptr() + 220 (shared_ptr.h:220)
11 myapp                          0x887238 realm::Realm::~Realm() + 104 (shared_realm.cpp:104)
12 myapp                          0x54f3c8 std::__1::shared_ptr<realm::app::App>::~shared_ptr() + 220 (shared_ptr.h:220)
13 libobjc.A.dylib                0x8380 object_cxxDestructFromClass(objc_object*, objc_class*) + 116
14 libobjc.A.dylib                0x51b4 objc_destructInstance + 80
15 libobjc.A.dylib                0xea00 _objc_rootDealloc + 80
16 myapp                          0x65ebe4 -[RLMRealm dealloc] + 941 (RLMRealm.mm:941)
17 libobjc.A.dylib                0x7b14 AutoreleasePoolPage::releaseUntil(objc_object**) + 196
18 libobjc.A.dylib                0x3e54 objc_autoreleasePoolPop + 212
19 CoreFoundation                 0x13dd4 _CFAutoreleasePoolPop + 32
20 CoreFoundation                 0xcaf4 __CFRunLoopPerCalloutARPEnd + 48
21 CoreFoundation                 0xb748 __CFRunLoopRun + 2600
22 CoreFoundation                 0x1ebc8 CFRunLoopRunSpecific + 600
23 GraphicsServices               0x1374 GSEventRunModal + 164
24 UIKitCore                      0x514b58 -[UIApplication _run] + 1100
25 UIKitCore                      0x296098 UIApplicationMain + 364
26 myapp                          0x7418 main + 164 (<compiler-generated>:164)
27 ???                            0x107d61da4 (Missing)
Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x6bbc __pthread_kill + 8
1  libsystem_pthread.dylib        0xd854 pthread_kill + 208
2  libsystem_c.dylib              0x1f6ac abort + 124
3  myapp                          0x7b0ab4 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 128 (terminate.cpp:128)
4  myapp                          0x7b0df4 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 123 (terminate.cpp:123)
5  myapp                          0x7b0b70 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 133 (terminate.cpp:133)
6  myapp                          0x4f35e8 realm::Array::get(char const*, unsigned long) + 1355 (array.cpp:1355)
7  myapp                          0x6d59e4 realm::ParentNode::aggregate_local(realm::QueryStateBase*, unsigned long, unsigned long, unsigned long, realm::ArrayPayload*) + 119 (query_engine.cpp:119)
8  myapp                          0x6a67f4 realm::Query::aggregate_internal(realm::ParentNode*, realm::QueryStateBase*, unsigned long, unsigned long, realm::ArrayPayload*) const + 1041 (query.cpp:1041)
9  myapp                          0x6ac3f8 realm::util::FunctionRef<bool (realm::Cluster const*)>::FunctionRef<realm::Query::do_count(unsigned long) const::$_4&>(realm::Query::do_count(unsigned long) const::$_4&)::'lambda'(void*, realm::Cluster const*)::__invoke(void*, realm::Cluster const*) + 1596 (query.cpp:1596)
10 myapp                          0x51d830 realm::ClusterNodeInner::traverse(realm::util::FunctionRef<bool (realm::Cluster const*)>, long long) const + 416 (cluster_tree.cpp:416)
11 myapp                          0x51ee30 realm::ClusterTree::traverse(realm::util::FunctionRef<bool (realm::Cluster const*)>) const + 1002 (cluster_tree.cpp:1002)
12 myapp                          0x6a91b8 realm::Query::do_count(unsigned long) const + 93 (query_state.hpp:93)
13 myapp                          0x6a942c realm::Query::count(realm::DescriptorOrdering const&) + 1664 (query.cpp:1664)
14 myapp                          0x5fc010 realm::Results::size() + 136 (results.cpp:136)
15 myapp                          0x42101c -[RLMResults count] + 148 (RLMResults.mm:148)
16 myapp                          0x47c6c0 RealmCollectionImpl.count.getter + 37 (RealmCollectionImpl.swift:37)
17 myapp                          0x81fea8 IssueDownloadMetadataDatabaseRepositoryRealm.countPendingDownloads(_:) + 114 (IssueDownloadMetadataDatabaseRepositoryRealm.swift:114)

rserentill avatar Sep 20 '22 17:09 rserentill

@rserentill can you open a new issue, the stack traces indicates that the errors are different from the one in this issue. It does seem like this errors may be cause for different reasons. Fill out the form so we can take a closer look into this.

dianaafanador3 avatar Sep 20 '22 20:09 dianaafanador3

Hi @dianaafanador3, sure I will open a separate issue. Thank you!

rserentill avatar Sep 21 '22 08:09 rserentill

Can you potentially provide the realm file from an affected user? This issue looks so well known to me, it would be great to see if the file is corrupted in similar ways than mine were.

BlueCobold avatar Sep 23 '22 07:09 BlueCobold

No unfortunately it happens only in live app :(

mmar001 avatar Sep 23 '22 08:09 mmar001

@mmar001 Can you pass the queue you are using to the queue parameter when opening the Realm and let us know if that helps?

leemaguire avatar Sep 26 '22 09:09 leemaguire