realm / realm-core

Core database component for the Realm Mobile Database SDKs
https://realm.io
Apache License 2.0
1.01k stars 155 forks source link

Multiple Crashes in Realm Core v14.12.0 #7993

Open NZQN23 opened 3 weeks ago

NZQN23 commented 3 weeks ago

SDK and version

SDK : RealmSwift Version: 10.52.3

Observations

Crash log / stacktrace

Incident Identifier: ………….
Distributor ID:      com.apple.AppStore
Hardware Model:      iPhone13,3
Process:             MyAppName [10111]
Path:                /private/var/containers/Bundle/Application/………../MyAppName.app/MyAppName
Identifier:          my.company.MyAppName
Version:             5.0.10 (5001007)
AppStoreTools:       15F31e
AppVariant:          1:iPhone13,3:17.4
Code Type:           ARM-64 (Native)
Role:                Non UI
Parent Process:      launchd [1]
Coalition:           my.company.MyAppName [2336]

Date/Time:           2024-08-21 12:32:28.7538 +0200
Launch Time:         2024-08-21 12:32:27.6559 +0200
OS Version:          iPhone OS 17.5.1 (21F90)
Release Type:        User
Baseband Version:    4.50.06
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: MyAppName [10111]

Triggered by Thread:  1

Thread 0:
0   libsystem_kernel.dylib          0x00000001e9fe0808 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib          0x00000001e9fe3f20 mach_msg_overwrite + 436 (mach_msg.c:0)
2   libsystem_kernel.dylib          0x00000001e9fe3d60 mach_msg + 24 (mach_msg.c:323)
3   CoreFoundation                  0x00000001a0f00f5c __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2624)
4   CoreFoundation                  0x00000001a0f00600 __CFRunLoopRun + 1208 (CFRunLoop.c:3007)
5   CoreFoundation                  0x00000001a0effcd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
6   GraphicsServices                0x00000001e5db01a8 GSEventRunModal + 164 (GSEvent.c:2196)
7   UIKitCore                       0x00000001a353890c -[UIApplication _run] + 888 (UIApplication.m:3713)
8   UIKitCore                       0x00000001a35ec9d0 UIApplicationMain + 340 (UIApplication.m:5303)
9   UIKitCore                       0x00000001a3766384 UIApplicationMain(_:_:_:_:) + 104 (UIKit.swift:539)
10  MyAppName                           0x0000000102ddc978 specialized static UIApplicationDelegate.main() + 28 (<compiler-generated>:10)
11  MyAppName                           0x0000000102ddc978 static AppDelegate.$main() + 28 (AppDelegate.swift:0)
12  MyAppName                           0x0000000102ddc978 main + 116
13  dyld                            0x00000001c45b1e4c start + 2240 (dyldMain.cpp:1298)

Thread 1 Crashed:
0   libsystem_kernel.dylib          0x00000001e9feb42c __pthread_kill + 8 (:-1)
1   libsystem_c.dylib               0x00000001a8e8eba0 abort + 180 (abort.c:118)
2   Realm                           0x0000000103af5978 please_report_this_issue_in_github_realm_realm_core_v_14_12_0 + 12
3   Realm                           0x0000000103af5c74 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) + 244
4   Realm                           0x0000000103af5b18 realm::util::terminate_with_info(char const*, char const*, long, char const*, std::initializer_list<realm::util::Printable>&&) + 396
5   Realm                           0x0000000103931c48 void realm::util::terminate_with_info<unsigned long&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(char const*, int, char const*, char const*, unsigned long... + 92
6   Realm                           0x00000001039331dc realm::SlabAlloc::do_free(unsigned long, char*) + 1396
7   Realm                           0x0000000103abc69c realm::WrappedAllocator::do_free(unsigned long, char*) + 24
8   Realm                           0x00000001039458e4 realm::ArraySmallBlobs::destroy() + 60
9   Realm                           0x000000010394e090 realm::ArrayString::upgrade_leaf(unsigned long) + 272
10  Realm                           0x000000010394e8a4 realm::ArrayString::insert(unsigned long, realm::StringData) + 40
11  Realm                           0x0000000103962614 void realm::Cluster::do_insert_row<realm::ArrayString>(unsigned long, realm::ColKey, realm::Mixed, bool) + 168
12  Realm                           0x000000010395a48c realm::Cluster::insert_row(unsigned long, realm::ClusterNode::RowKey, realm::FieldValues const&) + 692
13  Realm                           0x000000010395c5f0 realm::Cluster::insert(realm::ClusterNode::RowKey, realm::FieldValues const&, realm::ClusterNode::State&) + 240
14  Realm                           0x000000010396dc2c realm::ClusterNodeInner::insert(realm::ClusterNode::RowKey, realm::FieldValues const&, realm::ClusterNode::State&)::$_5::operator()(realm::ClusterNode*, realm::ClusterNodeInner::ChildInfo&) const + 72
15  Realm                           0x0000000103967fe8 realm::ClusterNodeInner::insert(realm::ClusterNode::RowKey, realm::FieldValues const&, realm::ClusterNode::State&) + 228
16  Realm                           0x000000010396dc2c realm::ClusterNodeInner::insert(realm::ClusterNode::RowKey, realm::FieldValues const&, realm::ClusterNode::State&)::$_5::operator()(realm::ClusterNode*, realm::ClusterNodeInner::ChildInfo&) const + 72
17  Realm                           0x00000001039680a8 realm::ClusterNodeInner::insert(realm::ClusterNode::RowKey, realm::FieldValues const&, realm::ClusterNode::State&) + 420
18  Realm                           0x000000010396b0e8 realm::ClusterTree::insert_fast(realm::ObjKey, realm::FieldValues const&, realm::ClusterNode::State&) + 44
19  Realm                           0x000000010396b254 realm::ClusterTree::insert(realm::ObjKey, realm::FieldValues const&) + 64
20  Realm                           0x0000000103ab9594 realm::Table::create_object_with_primary_key(realm::Mixed const&, realm::FieldValues&&, realm::Table::UpdateMode, bool*) + 944
21  Realm                           0x00000001037e9ec0 realm::Table::create_object_with_primary_key(realm::Mixed const&, bool*) + 80 (table.hpp:306)
22  Realm                           0x00000001037de070 realm::Object realm::Object::create<objc_object* __strong, RLMAccessorContext>(RLMAccessorContext&, std::__1::shared_ptr<realm::Realm> const&, realm::ObjectSchema const&, objc_object* __strong, rea... + 628 (object_accessor.hpp:342)
23  Realm                           0x00000001037ddab0 RLMAccessorContext::createObject(objc_object*, realm::CreatePolicy, bool, realm::ObjKey) + 760 (RLMAccessor.mm:1120)
24  Realm                           0x0000000103838350 RLMAddObjectToRealm + 184 (RLMObjectStore.mm:118)
25  RealmSwift                      0x00000001041a15a0 Realm.add(_:update:) + 16 (Realm.swift:554)
26  RealmSwift                      0x00000001041a15a0 Realm.add<A>(_:update:) + 316 (Realm.swift:578)
27  MyAppName                           0x0000000102ef8e54 closure #1 in closure #1 in closure #1 in databaseWrite(objects:fixingOptions:syncOptions:completion:) + 100 (DatabaseHandling.swift:103)
28  MyAppName                           0x0000000102ef8e7c partial apply for closure #1 in closure #1 in closure #1 in databaseWrite(objects:fixingOptions:syncOptions:completion:) + 16 (<compiler-generated>:0)
29  RealmSwift                      0x00000001041a0abc Realm.write<A>(withoutNotifying:_:) + 128 (Realm.swift:265)
30  MyAppName                           0x0000000102ef8d34 closure #1 in closure #1 in databaseWrite(objects:fixingOptions:syncOptions:completion:) + 580 (DatabaseHandling.swift:101)
31  MyAppName                           0x0000000102ef8a70 specialized autoreleasepool<A>(invoking:) + 36 (<compiler-generated>:0)
32  MyAppName                           0x0000000102ef8a70 closure #1 in databaseWrite(objects:fixingOptions:syncOptions:completion:) + 80 (DatabaseHandling.swift:97)
33  MyAppName                           0x0000000102ef5a5c thunk for @escaping @callee_guaranteed @Sendable () -> () + 28 (<compiler-generated>:0)
34  libdispatch.dylib               0x00000001a8dd413c _dispatch_call_block_and_release + 32 (init.c:1530)
35  libdispatch.dylib               0x00000001a8dd5dd4 _dispatch_client_callout + 20 (object.m:576)
36  libdispatch.dylib               0x00000001a8ddd400 _dispatch_lane_serial_drain + 748 (queue.c:3900)
37  libdispatch.dylib               0x00000001a8dddf30 _dispatch_lane_invoke + 380 (queue.c:3991)
38  libdispatch.dylib               0x00000001a8de8cb4 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:6998)
39  libdispatch.dylib               0x00000001a8de8528 _dispatch_workloop_worker_thread + 404 (queue.c:6592)
40  libsystem_pthread.dylib         0x00000001fdd87934 _pthread_wqthread + 288 (pthread.c:2696)
41  libsystem_pthread.dylib         0x00000001fdd840cc start_wqthread + 8 (:-1)

Thread 2:
0   libsystem_pthread.dylib         0x00000001fdd840c4 start_wqthread + 0 (:-1)

Thread 3:
0   libsystem_pthread.dylib         0x00000001fdd840c4 start_wqthread + 0 (:-1)

Thread 4:
0   libsystem_pthread.dylib         0x00000001fdd840c4 start_wqthread + 0 (:-1)

Thread 5:
0   libsystem_kernel.dylib          0x00000001e9fe8448 ftruncate + 8 (:-1)
1   Realm                           0x0000000103991e1c realm::DB::open(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, realm::DBOptions const&) + 1492
2   Realm                           0x0000000103999acc realm::DB::create(std::__1::unique_ptr<realm::Replication, std::__1::default_delete<realm::Replication>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&... + 164
3   Realm                           0x0000000103bee4d0 realm::_impl::RealmCoordinator::open_db() + 1012
4   Realm                           0x0000000103bef210 realm::_impl::RealmCoordinator::do_get_realm(realm::RealmConfig&&, std::__1::shared_ptr<realm::Realm>&, std::__1::optional<realm::VersionID>, realm::util::CheckedUniqueLock&, bool) + 76
5   Realm                           0x0000000103bef12c realm::_impl::RealmCoordinator::get_realm(realm::RealmConfig, std::__1::optional<realm::VersionID>) + 484
6   Realm                           0x0000000103c38da0 realm::Realm::get_shared_realm(realm::RealmConfig) + 120
7   Realm                           0x0000000103908c64 +[RLMRealm realmWithConfiguration:confinedTo:error:] + 896 (RLMRealm.mm:430)
8   Realm                           0x0000000103908884 +[RLMRealm realmWithConfiguration:queue:error:] + 80 (RLMRealm.mm:395)
9   RealmSwift                      0x000000010419ff04 @nonobjc RLMRealm.__allocating_init(configuration:queue:) + 92 (<compiler-generated>:0)
10  RealmSwift                      0x00000001041a0534 Realm.init(configuration:queue:) + 116 (Realm.swift:95)
11  MyAppName                           0x0000000102c721d8 closure #1 in closure #1 in logEvent(function:event:data:location:critical:) + 1544 (Logging.swift:50)
12  MyAppName                           0x0000000102c71aa8 specialized autoreleasepool<A>(invoking:) + 52 (<compiler-generated>:0)
13  MyAppName                           0x0000000102c71aa8 closure #1 in logEvent(function:event:data:location:critical:) + 120 (Logging.swift:19)
14  MyAppName                           0x0000000102c71bac partial apply for closure #1 in logEvent(function:event:data:location:critical:) + 68 (<compiler-generated>:0)
15  MyAppName                           0x0000000102ef5a5c thunk for @escaping @callee_guaranteed @Sendable () -> () + 28 (<compiler-generated>:0)
16  libdispatch.dylib               0x00000001a8dd413c _dispatch_call_block_and_release + 32 (init.c:1530)
17  libdispatch.dylib               0x00000001a8dd5dd4 _dispatch_client_callout + 20 (object.m:576)
18  libdispatch.dylib               0x00000001a8ddd400 _dispatch_lane_serial_drain + 748 (queue.c:3900)
19  libdispatch.dylib               0x00000001a8dddf30 _dispatch_lane_invoke + 380 (queue.c:3991)
20  libdispatch.dylib               0x00000001a8de8cb4 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:6998)
21  libdispatch.dylib               0x00000001a8de8528 _dispatch_workloop_worker_thread + 404 (queue.c:6592)
22  libsystem_pthread.dylib         0x00000001fdd87934 _pthread_wqthread + 288 (pthread.c:2696)
23  libsystem_pthread.dylib         0x00000001fdd840cc start_wqthread + 8 (:-1)

Thread 6 name:
Thread 6:
0   libsystem_kernel.dylib          0x00000001e9fe0808 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib          0x00000001e9fe3f20 mach_msg_overwrite + 436 (mach_msg.c:0)
2   libsystem_kernel.dylib          0x00000001e9fe3d60 mach_msg + 24 (mach_msg.c:323)
3   CoreFoundation                  0x00000001a0f00f5c __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2624)
4   CoreFoundation                  0x00000001a0f00600 __CFRunLoopRun + 1208 (CFRunLoop.c:3007)
5   CoreFoundation                  0x00000001a0effcd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
6   Foundation                      0x000000019fe20e4c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
7   Foundation                      0x000000019fe20c9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420)
8   UIKitCore                       0x00000001a354c640 -[UIEventFetcher threadMain] + 420 (UIEventFetcher.m:1207)
9   Foundation                      0x000000019fe37718 __NSThread__start__ + 732 (NSThread.m:991)
10  libsystem_pthread.dylib         0x00000001fdd8906c _pthread_start + 136 (pthread.c:931)
11  libsystem_pthread.dylib         0x00000001fdd840d8 thread_start + 8 (:-1)

Thread 7 name:
Thread 7:
0   libsystem_kernel.dylib          0x00000001e9fe7608 kevent + 8 (:-1)
1   Realm                           0x0000000103bd62d0 void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, realm::_impl::ExternalCommitHelper:... + 56
2   libsystem_pthread.dylib         0x00000001fdd8906c _pthread_start + 136 (pthread.c:931)
3   libsystem_pthread.dylib         0x00000001fdd840d8 thread_start + 8 (:-1)

Thread 1 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000004   x5: 0x000000010681d000   x6: 0x0000000000000400   x7: 0x0000000000000000
    x8: 0xdc226aaf6a051b91   x9: 0xdc226aae07292b91  x10: 0x00000000007d9a00  x11: 0x0000000000bf3d01
   x12: 0x000000010681c000  x13: 0x0000000000003fff  x14: 0x00000000000000a5  x15: 0x000000010681cc00
   x16: 0x0000000000000148  x17: 0x000000016d2c3000  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000000001907  x21: 0x000000016d2c30e0  x22: 0x000000016d2c0c78  x23: 0x000000016d2c0c78
   x24: 0x0000000103d49286  x25: 0x000000016d2c0c80  x26: 0x000000016d2c0c68  x27: 0x0000000103dac000
   x28: 0x0000000103dac040   fp: 0x000000016d2c0bb0   lr: 0x00000001fdd8ac0c
    sp: 0x000000016d2c0b90   pc: 0x00000001e9feb42c cpsr: 0x40001000
   esr: 0x56000080  Address size fault

Binary Images:
        0x102bc4000 -         0x102f67fff MyAppName arm64  <9d4b2823f1183ee7b5949da6e71bf645> /private/var/containers/Bundle/Application/......../MyAppName.app/MyAppName
        0x103054000 -         0x10305ffff OpenLocationCode arm64  <2cac8daa65093396bed1f29c5f83d893> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/OpenLocationCode.framework/OpenLocationCode
        0x1031ec000 -         0x1031f7fff libobjc-trampolines.dylib arm64e  <2e2c05f8377a30899ad91926d284dd03> /private/preboot/Cryptexes/OS/usr/lib/libobjc-trampolines.dylib
        0x10351c000 -         0x10353bfff AcknowList arm64  <e6d9ee5735ed3247b7990565ceecc5e4> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/AcknowList.framework/AcknowList
        0x103580000 -         0x1035d3fff CoreGPX arm64  <15cdb884532a3ef1bed8033a7a2154ac> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/CoreGPX.framework/CoreGPX
        0x103670000 -         0x10369bfff Fastis arm64  <b9b5b807e8ae33b0990a3b221f79f6ee> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/Fastis.framework/Fastis
        0x1036ec000 -         0x10373ffff JTAppleCalendar arm64  <2d54483c58e4355ba629b68f4fdb0155> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/JTAppleCalendar.framework/JTAppleCalendar
        0x1037b0000 -         0x1037bbfff PrettyCards arm64  <de64772208f534f5b32a98b8f90d769f> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/PrettyCards.framework/PrettyCards
        0x1037d4000 -         0x103d8ffff Realm arm64  <89ec9a893b253f2fb3b1a631d023e7d2> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/Realm.framework/Realm
        0x104130000 -         0x104213fff RealmSwift arm64  <55585323bb2f34c2812c9a1001165adf> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/RealmSwift.framework/RealmSwift
        0x104418000 -         0x104493fff TPPDF arm64  <eae0ce6cd3253b0092531d828622f67a> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/TPPDF.framework/TPPDF
        0x104564000 -         0x10456bfff TimeZoneLocate arm64  <838bdc694a913b6d990089db02d88766> /private/var/containers/Bundle/Application/......../MyAppName.app/Frameworks/TimeZoneLocate.framework/TimeZoneLocate
        0x19fd59000 -         0x1a08cefff Foundation arm64e  <3d3a12e3f5e9361fb00a4a5e8861aa55> /System/Library/Frameworks/Foundation.framework/Foundation
        0x1a0ead000 -         0x1a13dafff CoreFoundation arm64e  <00e76a98210c3cb5930bf236807ff24c> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
        0x1a312e000 -         0x1a4c4efff UIKitCore arm64e  <1741fa374e53371e8daed611aab0043d> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
        0x1a8dd2000 -         0x1a8e18fff libdispatch.dylib arm64e  <81d355df266a3010bab8113b76a206c1> /usr/lib/system/libdispatch.dylib
        0x1a8e19000 -         0x1a8e96ff3 libsystem_c.dylib arm64e  <b122f07fa15637f3a22d64627c0c4b24> /usr/lib/system/libsystem_c.dylib
        0x1c4575000 -         0x1c4601ef7 dyld arm64e  <71846eacee653697bf7d790b6a07dcdb> /usr/lib/dyld
        0x1e5daf000 -         0x1e5db7fff GraphicsServices arm64e  <c19b2aeb6aa83f998a53f76c7a0d98fe> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
        0x1e9fdf000 -         0x1ea018fef libsystem_kernel.dylib arm64e  <13b5134e819c3baab3004856112114cb> /usr/lib/system/libsystem_kernel.dylib
        0x1fdd83000 -         0x1fdd8fff3 libsystem_pthread.dylib arm64e  <1196b6c3333d3450818ff3663484b8eb> /usr/lib/system/libsystem_pthread.dylib

EOF
sync-by-unito[bot] commented 3 weeks ago

➤ PM Bot commented:

Jira ticket: RCORE-2239

nicola-cab commented 2 weeks ago

Hello, thank you for reporting this. I am trying to find the root cause of the issue you have reported. I have a couple of questions:

  1. Do you happen to have the realm file of the apps that are crashing? If yes, could you share the file with us?

  2. From the stack trace you attached. It seems thread5 is opening a realm file, and thread1 is actually adding a new object in the database with a string property. Are those threads sharing the same realm file? Could I assume that and set up a similar test scenario?

  3. Can you confirm that this is not happening at all using any realm core < 14.12.0? Provided the same database file is opened in the same scenario (with multiple threads).

Thanks.

NZQN23 commented 2 weeks ago

Hi @nicola-cab!

  1. No. I don't have access to the Realm files.
  2. No. Different Realm files on different DispatchQueues.
  3. Yes. No crashes with previous Realm Core Versions. Also, I haven't made any changes in Database handling for quite some time. Thus, I must have been introduced by a Realm Update.
jedelbo commented 2 weeks ago

@NZQN23 from which version did you upgrade from?

NZQN23 commented 2 weeks ago

@jedelbo From Realm Swift 10.52.2 to 10.52.3.

NZQN23 commented 1 week ago

Until now this problem has accumulated over 200 crashes as per App Store Connect. Is there any chance to catch such issues? It seems that realm.write() creates the crash.

jedelbo commented 1 week ago

@NZQN23 Can you elaborate on what you mean by "realm.write() creates the crash"?

NZQN23 commented 1 week ago

From what I've seen, the app crashes while trying to execute realm.write(). Maybe I'm wrong. I just need to know if there's any chance at all to catch this issue at all as it poses a major problem right now.

Bildschirmfoto 2024-08-30 um 16 40 50
jedelbo commented 1 week ago

@NZQN23 Byt why do you think it is during realm.write()? The stacktrace you provided suggests that it happens during creation of an object.

NZQN23 commented 1 week ago

@jedelbo I already said earlier that I might have mis-interpreted that Stacktrace. So nevermind.

BUT: I repeat my question what I can do about it. Why do I follow the request of reporting crashes here (please_report_this_issue_in_github_realm_realm_core) if I don't get actual help?

jedelbo commented 1 week ago

@NZQN23 we really appreciate that you report the crashes and we will do what we can to help you, but there is only litte information to work from. I have gone through all the changes we have done in realm-core between v14.11.0 and v14.12.0, but nothing seems to touch areas of the code that would be able to produce a crash like the one above. But obviously something has changed - your numbers clearly indicates that, but what exactly that is is hard for me to tell. Have you considered going back to v10.52.2?