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

Cannot initialize value array during object creation

Open rist opened this issue 2 years ago • 5 comments

SDK and version

SDK : Cocoa Version: 11.9.0

This happens on tvOS 15.3

Observations

  • How frequent do the crash occur? Haven't seen much instances yet
  • Does it happen in production or during dev/test? Production
  • Can the crash be reproduced by you? Unfortunately no
  • Can you provide instructions for how we can reproduce it? Unfortunately no

Crash log / stacktrace

OS Version: tvOS 15.3 (19K547)
Report Version: 104

Exception Type: Unknown (SIGABRT)
Crashed Thread: 5

Application Specific Information:
Assertion failed: get_wtype_from_header(get_header_from_data(m_data)) == wtype_Bits

Thread 5 Crashed:
0   libsystem_kernel.dylib          0x319fa46f4         __pthread_kill
1   libsystem_pthread.dylib         0x31a0ec778         pthread_kill
2   libsystem_c.dylib               0x319e1e0c8         abort
3   MUBITV                          0x2014a8464         please_report_this_issue_in_github_realm_realm_core (terminate.cpp:50)
4   MUBITV                          0x2014a8798         realm::util::terminate_internal (terminate.cpp:123)
5   MUBITV                          0x2014a88d0         realm::util::terminate (terminate.cpp:140)
6   MUBITV                          0x2010427a0         realm::util::terminate<T> (terminate.hpp:45)
7   MUBITV                          0x20127e79c         realm::Node::calc_byte_len (node.cpp:45)
8   MUBITV                          0x20127ea18         realm::Node::do_copy_on_write (node.cpp:131)
9   MUBITV                          0x2011af6dc         [inlined] copy_on_write (node.hpp:299)
10  MUBITV                          0x2011af6dc         realm::Array::set (array.cpp:378)
11  MUBITV                          0x20128806c         realm::Obj::set<T> (obj.cpp:1345)
12  MUBITV                          0x200fd8df0         [inlined] operator()<T> (object_accessor.hpp:115)
13  MUBITV                          0x200fd8df0         [inlined] switch_on_type<T> (property.hpp:227)
14  MUBITV                          0x200fd8df0         realm::Object::set_property_value_impl<T> (object_accessor.hpp:173)
15  MUBITV                          0x200fd0e20         realm::Object::create<T> (object_accessor.hpp:355)
16  MUBITV                          0x200fd05d8         RLMAccessorContext::createObject (RLMAccessor.mm:1093)
17  MUBITV                          0x200fd95d8         [inlined] unbox<T> (RLMAccessor.mm:1125)
18  MUBITV                          0x200fd95d8         [inlined] operator() (object_accessor.hpp:91)
19  MUBITV                          0x200fd95d8         [inlined] switch_on_type<T> (property.hpp:241)
20  MUBITV                          0x200fd95d8         realm::Object::set_property_value_impl<T> (object_accessor.hpp:173)
21  MUBITV                          0x200fd0e20         realm::Object::create<T> (object_accessor.hpp:355)
22  MUBITV                          0x200fd05d8         RLMAccessorContext::createObject (RLMAccessor.mm:1093)
23  MUBITV                          0x20101a9fc         RLMAddObjectToRealm (RLMObjectStore.mm:138)
24  MUBITV                          0x2010e47d0         -[RLMRealm addOrUpdateObject:] (RLMRealm.mm:821)
25  MUBITV                          0x2010e4988         -[RLMRealm addOrUpdateObjects:] (RLMRealm.mm:831)
26  MUBITV                          0x200f73a34         LayoutItem.updateData (LibraryResource.swift:155)
27  MUBITV                          0x200f628d8         Persistence.backgroundSave (Persistence.swift:269)
28  MUBITV                          0x200f64ee8         [inlined] <redacted>
29  MUBITV                          0x200f64ee8         thunk for closure
30  MUBITV                          0x200f625ec         thunk for closure
31  MUBITV                          0x2010e4174         -[RLMRealm transactionWithoutNotifying:block:error:] (RLMRealm.mm:694)
32  MUBITV                          0x2010e40f8         -[RLMRealm transactionWithBlock:error:] (RLMRealm.mm:685)
33  MUBITV                          0x200f62728         Persistence.backgroundSave (Persistence.swift:268)
34  MUBITV                          0x200f8f7ec         thunk for closure
35  MUBITV                          0x200f64e70         thunk for closure
36  libswiftObjectiveC.dylib        0x34cac5070         autoreleasepool<T>
37  MUBITV                          0x200f64e1c         [inlined] <redacted> (Persistence.swift:265)
38  MUBITV                          0x200f64e1c         Persistence.backgroundSave
39  MUBITV                          0x200d737fc         thunk for closure
40  libdispatch.dylib               0x319cb5714         <redacted>
41  libdispatch.dylib               0x319cb6f84         <redacted>
42  libdispatch.dylib               0x319cc70c4         <redacted>
43  libdispatch.dylib               0x319cc7790         <redacted>
44  libsystem_pthread.dylib         0x31a0ed440         _pthread_wqthread

Thread 0
0   libsystem_kernel.dylib          0x319fa44c4         __psynch_cvwait
1   libsystem_pthread.dylib         0x31a0ef02c         <redacted>
2   libc++.1.dylib                  0x319a1e588         std::__1::condition_variable::wait
3   MUBITV                          0x2011e74d8         realm::Transaction::wait_for_async_completion (db.hpp:728)
4   MUBITV                          0x201322b48         realm::Realm::begin_transaction (shared_realm.cpp:885)
5   MUBITV                          0x2010e3e68         -[RLMRealm beginWriteTransactionWithError:] (RLMRealm.mm:645)
6   MUBITV                          0x2010e4168         -[RLMRealm transactionWithoutNotifying:block:error:] (RLMRealm.mm:693)
7   MUBITV                          0x2010e40f8         -[RLMRealm transactionWithBlock:error:] (RLMRealm.mm:685)
8   MUBITV                          0x200f63050         Persistence.save (Persistence.swift:254)
9   MUBITV                          0x200d8bc40         [inlined] save
10  MUBITV                          0x200d8bc40         UserHelper.update (UserHelper.swift:37)
11  MUBITV                          0x200f92c10         [inlined] update
12  MUBITV                          0x200f92c10         UserResource.refreshUser (Resource.swift:200)
13  MUBITV                          0x200f52be4         [inlined] <redacted>
14  MUBITV                          0x200f52be4         thunk for closure
15  MUBITV                          0x200f3fb3c         API.requestObject<T>
16  MUBITV                          0x200f52df4         API.requestObject<T>
17  MUBITV                          0x201571488         DownloadRequest._response<T>
18  MUBITV                          0x201502e8c         thunk for closure
19  libdispatch.dylib               0x319cb5714         <redacted>
20  libdispatch.dylib               0x319cb6f84         <redacted>
21  libdispatch.dylib               0x319cc4164         _dispatch_main_queue_callback_4CF
22  CoreFoundation                  0x31a754698         <redacted>
23  CoreFoundation                  0x31a74eb18         <redacted>
24  CoreFoundation                  0x31a74dbf4         CFRunLoopRunSpecific
25  GraphicsServices                0x320ba8afc         GSEventRunModal
26  UIKitCore                       0x392dbecd0         <redacted>
27  UIKitCore                       0x392dc40cc         UIApplicationMain
28  MUBITV                          0x200d474f0         main (ReviewModels.swift:13)
29  <unknown>                       0x101c8d1d0         <redacted>

Thread 1
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 2
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 3
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 4 name: com.apple.uikit.eventfetch-thread
0   libsystem_kernel.dylib          0x319f7fe00         mach_msg_trap
1   libsystem_kernel.dylib          0x319f7f1e0         mach_msg
2   CoreFoundation                  0x31a7541d4         <redacted>
3   CoreFoundation                  0x31a74e5d8         <redacted>
4   CoreFoundation                  0x31a74dbf4         CFRunLoopRunSpecific
5   Foundation                      0x31c11102c         <redacted>
6   Foundation                      0x31c1112e4         <redacted>
7   UIKitCore                       0x392e634a8         <redacted>
8   Foundation                      0x31c137f3c         <redacted>
9   libsystem_pthread.dylib         0x31a0eb914         _pthread_start

Thread 5 Crashed:
0   libsystem_kernel.dylib          0x319fa46f4         __pthread_kill
1   libsystem_pthread.dylib         0x31a0ec778         pthread_kill
2   libsystem_c.dylib               0x319e1e0c8         abort
3   MUBITV                          0x2014a8464         please_report_this_issue_in_github_realm_realm_core (terminate.cpp:50)
4   MUBITV                          0x2014a8798         realm::util::terminate_internal (terminate.cpp:123)
5   MUBITV                          0x2014a88d0         realm::util::terminate (terminate.cpp:140)
6   MUBITV                          0x2010427a0         realm::util::terminate<T> (terminate.hpp:45)
7   MUBITV                          0x20127e79c         realm::Node::calc_byte_len (node.cpp:45)
8   MUBITV                          0x20127ea18         realm::Node::do_copy_on_write (node.cpp:131)
9   MUBITV                          0x2011af6dc         [inlined] copy_on_write (node.hpp:299)
10  MUBITV                          0x2011af6dc         realm::Array::set (array.cpp:378)
11  MUBITV                          0x20128806c         realm::Obj::set<T> (obj.cpp:1345)
12  MUBITV                          0x200fd8df0         [inlined] operator()<T> (object_accessor.hpp:115)
13  MUBITV                          0x200fd8df0         [inlined] switch_on_type<T> (property.hpp:227)
14  MUBITV                          0x200fd8df0         realm::Object::set_property_value_impl<T> (object_accessor.hpp:173)
15  MUBITV                          0x200fd0e20         realm::Object::create<T> (object_accessor.hpp:355)
16  MUBITV                          0x200fd05d8         RLMAccessorContext::createObject (RLMAccessor.mm:1093)
17  MUBITV                          0x200fd95d8         [inlined] unbox<T> (RLMAccessor.mm:1125)
18  MUBITV                          0x200fd95d8         [inlined] operator() (object_accessor.hpp:91)
19  MUBITV                          0x200fd95d8         [inlined] switch_on_type<T> (property.hpp:241)
20  MUBITV                          0x200fd95d8         realm::Object::set_property_value_impl<T> (object_accessor.hpp:173)
21  MUBITV                          0x200fd0e20         realm::Object::create<T> (object_accessor.hpp:355)
22  MUBITV                          0x200fd05d8         RLMAccessorContext::createObject (RLMAccessor.mm:1093)
23  MUBITV                          0x20101a9fc         RLMAddObjectToRealm (RLMObjectStore.mm:138)
24  MUBITV                          0x2010e47d0         -[RLMRealm addOrUpdateObject:] (RLMRealm.mm:821)
25  MUBITV                          0x2010e4988         -[RLMRealm addOrUpdateObjects:] (RLMRealm.mm:831)
26  MUBITV                          0x200f73a34         LayoutItem.updateData (LibraryResource.swift:155)
27  MUBITV                          0x200f628d8         Persistence.backgroundSave (Persistence.swift:269)
28  MUBITV                          0x200f64ee8         [inlined] <redacted>
29  MUBITV                          0x200f64ee8         thunk for closure
30  MUBITV                          0x200f625ec         thunk for closure
31  MUBITV                          0x2010e4174         -[RLMRealm transactionWithoutNotifying:block:error:] (RLMRealm.mm:694)
32  MUBITV                          0x2010e40f8         -[RLMRealm transactionWithBlock:error:] (RLMRealm.mm:685)
33  MUBITV                          0x200f62728         Persistence.backgroundSave (Persistence.swift:268)
34  MUBITV                          0x200f8f7ec         thunk for closure
35  MUBITV                          0x200f64e70         thunk for closure
36  libswiftObjectiveC.dylib        0x34cac5070         autoreleasepool<T>
37  MUBITV                          0x200f64e1c         [inlined] <redacted> (Persistence.swift:265)
38  MUBITV                          0x200f64e1c         Persistence.backgroundSave
39  MUBITV                          0x200d737fc         thunk for closure
40  libdispatch.dylib               0x319cb5714         <redacted>
41  libdispatch.dylib               0x319cb6f84         <redacted>
42  libdispatch.dylib               0x319cc70c4         <redacted>
43  libdispatch.dylib               0x319cc7790         <redacted>
44  libsystem_pthread.dylib         0x31a0ed440         _pthread_wqthread

Thread 6
0   libsystem_pthread.dylib         0x31a0f4778         <redacted>

Thread 7
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 8
0   libsystem_kernel.dylib          0x319fa4a98         __semwait_signal
1   libsystem_c.dylib               0x319e1b750         nanosleep
2   libsystem_c.dylib               0x319e1b550         sleep
3   MUBITV                          0x20163e754         monitorCachedData (SentryCrashCachedData.c:139)
4   libsystem_pthread.dylib         0x31a0eb914         _pthread_start

Thread 9
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 10
0   libsystem_kernel.dylib          0x319fa6234         kevent
1   MUBITV                          0x201296bb8         realm::_impl::ExternalCommitHelper::listen (external_commit_helper.cpp:220)
2   MUBITV                          0x201296cb0         [inlined] operator() (external_commit_helper.cpp:176)
3   MUBITV                          0x201296cb0         [inlined] __invoke<T> (type_traits:3694)
4   MUBITV                          0x201296cb0         [inlined] __thread_execute<T> (thread:286)
5   MUBITV                          0x201296cb0         std::__1::__thread_proxy<T> (thread:297)
6   libsystem_pthread.dylib         0x31a0eb914         _pthread_start

Thread 11
0   libsystem_kernel.dylib          0x319f7fe00         mach_msg_trap
1   libsystem_kernel.dylib          0x319f7f1e0         mach_msg
2   CoreFoundation                  0x31a7541d4         <redacted>
3   CoreFoundation                  0x31a74e5d8         <redacted>
4   CoreFoundation                  0x31a74dbf4         CFRunLoopRunSpecific
5   CFNetwork                       0x31b915dc4         _CFURLStorageSessionCopyCache
6   Foundation                      0x31c137f3c         <redacted>
7   libsystem_pthread.dylib         0x31a0eb914         _pthread_start

Thread 12
0   libsystem_kernel.dylib          0x319fa44c4         __psynch_cvwait
1   libsystem_pthread.dylib         0x31a0ef02c         <redacted>
2   libc++.1.dylib                  0x319a1e588         std::__1::condition_variable::wait
3   MUBITV                          0x2011e4d80         realm::DB::AsyncCommitHelper::main (db.cpp:1774)
4   MUBITV                          0x2011e9cc0         [inlined] operator() (db.cpp:1695)
5   MUBITV                          0x2011e9cc0         [inlined] __invoke<T> (type_traits:3694)
6   MUBITV                          0x2011e9cc0         [inlined] __thread_execute<T> (thread:286)
7   MUBITV                          0x2011e9cc0         std::__1::__thread_proxy<T> (thread:297)
8   libsystem_pthread.dylib         0x31a0eb914         _pthread_start

Thread 13
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 14
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 15
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 16
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 17
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread

Thread 18
0   libsystem_kernel.dylib          0x319fa5334         __workq_kernreturn
1   libsystem_pthread.dylib         0x31a0ed4c8         _pthread_wqthread



EOF

rist avatar Mar 04 '22 08:03 rist

Hi @rist thanks for reporting this. Do you have some indication of the frequency of this crash? Are you able to share the schema of the classes that contain embedded objects?

Stating some observations from what I can tell from the stack trace provided, this assertion failure is triggered while writing a new object to the Realm, specifically, setting an non-nullable int property of a linked embedded object. The assertion implies that the incorrect width type is used, though what it actually is I cannot tell. @jedelbo do you have any ideas?

ironage avatar Mar 04 '22 23:03 ironage

Hi @rist thanks for reporting this. Do you have some indication of the frequency of this crash?

those realm crashes seem to become our most frequent crash in our tvOS app. I see the same crash happening multiple times for a single user.

Are you able to share the schema of the classes that contain embedded objects?

Embedded objects like this https://docs.mongodb.com/realm/sdk/swift/data-types/embedded-objects/ ? I think we don't use that feature.

We have some relations like @objc dynamic var audioTracks = RLMArray<Track>(objectClassName: Track.className()) and some instances where we store String arrays like

final class PlaybackLanguages: Object {
    @Persisted(primaryKey: true) var filmId: Int
    /// Audio languages stored as comma separated strings
    @Persisted var audioOptions: List<String>
…

I need to check but I assume it won't be a problem to share our Realm objects code with you privately

I'll attach more Realm crashes I found

Archive.zip

Stating some observations from what I can tell from the stack trace provided, this assertion failure is triggered while writing a new object to the Realm, specifically, setting an non-nullable int property of a linked embedded object. The assertion implies that the incorrect width type is used, though what it actually is I cannot tell. @jedelbo do you have any ideas?

rist avatar Mar 05 '22 19:03 rist

Another important observation - our app is available on iOS and tvOS. We see those crashes only on tvOS even though both releases use the same Realm version and the code for the persistence layer is shared between platforms

rist avatar Mar 07 '22 08:03 rist

It should be noted that the crashes shared above seem to be happening in totally different scenarios. So based on this, I don't have a good guess on what could be wrong here. If we can get a realm file, we might be able to find out more.

jedelbo avatar Mar 11 '22 14:03 jedelbo

Another example of a similar crash:

Application Specific Information:
Assertion failed: get_wtype_from_header(get_header_from_data(m_data)) == wtype_Bits
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x376810bbc         __pthread_kill
1   libsystem_pthread.dylib         0x3b7cb1854         pthread_kill
2   libsystem_c.dylib               0x3165d96ac         abort
3   Realm                           0x1056bdaf4         please_report_this_issue_in_github_realm_realm_core
4   Realm                           0x1056bdddc         __hidden#18408_
5   Realm                           0x1056bdc3c         realm::util::terminate
6   Realm                           0x10544f830         realm::util::terminate<T> (__hidden#544_:45)
7   Realm                           0x1055c6dc4         realm::Node::calc_byte_len
8   Realm                           0x1055c6e18         realm::Node::alloc
9   Realm                           0x1055229e0         __hidden#14147_
10  Realm                           0x105522e74         realm::Array::insert
11  Realm                           0x105530df4         realm::ArraySmallBlobs::insert
12  Realm                           0x1055493b8         __hidden#14398_
13  Realm                           0x105548a98         __hidden#14392_
14  Realm                           0x10568cf50         realm::TableClusterTree::for_each_and_every_column
15  Realm                           0x1055440a4         realm::Cluster::insert_row
16  Realm                           0x105546090         realm::Cluster::insert
17  Realm                           0x105556434         __hidden#14496_
18  Realm                           0x10555163c         realm::ClusterNodeInner::insert
19  Realm                           0x105554efc         realm::ClusterTree::insert_fast
20  Realm                           0x105555158         realm::ClusterTree::insert
21  Realm                           0x10568ca94         realm::TableClusterTree::insert
22  Realm                           0x10567fe90         realm::Table::create_object_with_primary_key
23  Realm                           0x1053db9c8         __hidden#231_ (__hidden#526_:260)
24  Realm                           0x1053d0e2c         realm::Object::create<T> (__hidden#472_:305)
25  Realm                           0x1053d07c8         RLMAccessorContext::createObject (__hidden#447_:1102)

jedelbo avatar Sep 02 '22 09:09 jedelbo