Hi, what this error message means?
Realm version: 0.98.6 and 0.98.5
Xcode version: 7.3
iOS/OSX version: 8 and newer
This is an internal error, you shouldn't be able to trigger as far as I can tell. Can you reproduce this exception? If so, could you provide us the stack trace and sample code to do that, so that we are able to determine the underlying cause?
I am getting this error occasionally. I am still trying to figure out when it occurs and what changes that I've made, cause it. Usually my last log shows a successful insert operation. After that I am getting exception with nowhere to point out. If I get more information, I will share with you. In the meantime I will send crashlytics report to your email.
We'll need more information, ideally steps to reproduce, in order to make progress on this.
This has happened to me immediately after running a migration. Sadly I was not lucid enough to capture the full stack trace. I have quite a few notification observes in my app that I register fairly early. For some reason I feel like these things are linked but I can't really say why.
First screenshot is when the exception is thrown, the second is at the time of crash.


From the backtrace it looks like RealmCoordinator::advance_to_ready is trying to "advance" to an older version. @tgoyne, any ideas?
Hi, I am ocasinally getting the same error.
Realm version: 0.98.6
Xcode version: 7.3
iOS/OSX version: 8 and newer
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 Zinomax 0x00000001001f20b8 0x100094000 + 1433784 (_mh_execute_header + 1433784)
1 Zinomax 0x0000000100155d1c 0x100094000 + 793884 (_mh_execute_header + 793884)
2 Zinomax 0x000000010014c8a4 0x100094000 + 755876 (_mh_execute_header + 755876)
3 CoreFoundation 0x0000000183594efc 0x1834b8000 + 904956 (
4 CoreFoundation 0x0000000183594990 0x1834b8000 + 903568 (
5 CoreFoundation 0x0000000183592690 0x1834b8000 + 894608 (
6 CoreFoundation 0x00000001834c1680 0x1834b8000 + 38528 (CFRunLoopRunSpecific + 384)
7 GraphicsServices 0x00000001849d0088 0x1849c4000 + 49288 (GSEventRunModal + 180)
8 UIKit 0x0000000188338d90 0x1882bc000 + 511376 (UIApplicationMain + 204)
9 Zinomax 0x00000001000df2b8 0x100094000 + 307896 (_mh_execute_header + 307896)
10 libdyld.dylib 0x00000001830628b8 0x183060000 + 10424 (
@palatov: Thanks for reporting that. Do you have any more information to share when the crash happens for you and what you're doing at that moment in your app? If you can reproduce it yourself and could share a sample project with us (confidentially to [email protected]), that would be vastly helpful for our further investigations.
I got the same exception;
I am using v0.98.8 in ObjC;
* thread #1: tid = 0xec3a80, 0x0000000107c29c6b libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
frame #0: 0x0000000107c29c6b libc++abi.dylib`__cxa_throw
* frame #1: 0x0000000102af341c houseqm`void realm::SharedGroup::advance_read<(anonymous namespace)::TransactLogValidator>(this=0x00007fe0b9852e00, observer=0x00007fff5d5dfde8, version_id=(version = 95, index = 25))::TransactLogValidator*, realm::SharedGroup::VersionID) + 220 at group_shared.hpp:924
frame #2: 0x0000000102af332b houseqm`void realm::_impl::SharedGroupFriend::advance_read<(anonymous namespace)::TransactLogValidator>(sg=0x00007fe0b9852e00, obs=0x00007fff5d5dfde8, ver=(version = 95, index = 25))::TransactLogValidator*, realm::SharedGroup::VersionID) + 59 at group_shared.hpp:1097
frame #3: 0x0000000102af32db houseqm`void realm::LangBindHelper::advance_read<(anonymous namespace)::TransactLogValidator>(sg=0x00007fe0b9852e00, observer=0x00007fff5d5dfde8, version=(version = 95, index = 25))::TransactLogValidator&&, realm::SharedGroup::VersionID) + 59 at lang_bind_helper.hpp:352
frame #4: 0x0000000102af3205 houseqm`auto realm::_impl::transaction::advance(this=0x00007fff5d5dfdd8, args=0x00007fff5d5dfde8)::$_0::operator()<(anonymous namespace)::TransactLogValidator&>((anonymous namespace)::TransactLogValidator&&&) const + 69 at transact_log_handler.cpp:438
frame #5: 0x0000000102af2e42 houseqm`(anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x00007fff5d5dfde8, context=0x00007fe0bb0eafe0, sg=0x00007fe0b9852e00, func=0x00007fff5d5dfdd8, validate_schema_changes=true)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SharedGroup::VersionID)::$_0&&, bool) + 1106 at transact_log_handler.cpp:222
frame #6: 0x0000000102af25de houseqm`(anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x00007fff5d5dfde8, context=0x00007fe0bb0eafe0, sg=0x00007fe0b9852e00, func=0x00007fff5d5dfdd8, validate_schema_changes=true)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SharedGroup::VersionID)::$_0&&, bool) + 62 at transact_log_handler.cpp:204
frame #7: 0x0000000102af258a houseqm`realm::_impl::transaction::advance(sg=0x00007fe0b9852e00, context=0x00007fe0bb0eafe0, version=(version = 95, index = 25)) + 90 at transact_log_handler.cpp:437
frame #8: 0x0000000102944816 houseqm`realm::_impl::RealmCoordinator::advance_to_ready(this=0x00007fe0bb039dd0, realm=0x00007fe0b8c7d7a0) + 966 at realm_coordinator.cpp:438
frame #9: 0x0000000102aec639 houseqm`realm::Realm::notify(this=0x00007fe0b8c7d7a0) + 329 at shared_realm.cpp:381
frame #10: 0x000000010291873f houseqm`realm::_impl::CachedRealm::CachedRealm(this=0x00000001029186d0, info=0x00007fe0b8ddf580)::$_0::operator()(void*) const + 79 at cached_realm.cpp:38
frame #11: 0x00000001029186e8 houseqm`realm::_impl::CachedRealm::CachedRealm(info=0x00007fe0b8ddf580)::$_0::__invoke(void*) + 24 at cached_realm.cpp:36
frame #12: 0x0000000103b5a301 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #13: 0x0000000103b5022c CoreFoundation`__CFRunLoopDoSources0 + 556
frame #14: 0x0000000103b4f6e3 CoreFoundation`__CFRunLoopRun + 867
frame #15: 0x0000000103b4f0f8 CoreFoundation`CFRunLoopRunSpecific + 488
frame #16: 0x0000000108f4bad2 GraphicsServices`GSEventRunModal + 161
frame #17: 0x000000010563df09 UIKit`UIApplicationMain + 171
frame #18: 0x000000010273425f houseqm`main(argc=7, argv=0x00007fff5d5e1588) + 111 at main.m:14
frame #19: 0x0000000107d6992d libdyld.dylib`start + 1
frame #20: 0x0000000107d6992d libdyld.dylib`start + 1
Hi all, I'm sorry you're affected by this issue. We're investigating what may be causing this but unfortunately we don't have much to go on at this point.
Any further information that you can provide that could help us identify what's causing this to happen would be very useful and very appreciated.
Full stack trace. Hoping this will be helpful.
Realm version: 0.98.6
Xcode version: 7.3
iOS/OSX version: 8 and newer
Fatal Exception: realm::LogicError: Bad version number
Crashed: com.twitter.crashlytics.ios.exception
0 My App 0x1001ad60c CLSProcessRecordAllThreads + 4296594956
1 My App 0x1001ad60c CLSProcessRecordAllThreads + 4296594956
2 My App 0x1001ada2c CLSProcessRecordAllThreads + 4296596012
3 My App 0x10019e8e0 CLSHandler + 4296534240
4 My App 0x1001abf30 __CLSExceptionRecord_block_invoke + 4296589104
5 libdispatch.dylib 0x1822d547c _dispatch_client_callout + 16
6 libdispatch.dylib 0x1822e0728 _dispatch_barrier_sync_f_invoke + 100
7 My App 0x1001ab9dc CLSExceptionRecord + 4296587740
8 My App 0x1001ab560 CLSTerminateHandler() + 4296586592
9 libc++abi.dylib 0x181ee2f44 std::__terminate(void (*)()) + 16
10 libc++abi.dylib 0x181ee2b10 __cxa_rethrow + 144
11 libobjc.A.dylib 0x181ef0120 objc_exception_rethrow + 44
12 CoreFoundation 0x182768db8 CFRunLoopRunSpecific + 552
13 GraphicsServices 0x184050088 GSEventRunModal + 180
14 UIKit 0x187a3df70 UIApplicationMain + 204
15 My App 0x10015627c main (AppDelegate.swift:17)
16 libdispatch.dylib 0x1823068b8 (Missing)
Thread
0 libsystem_kernel.dylib 0x182424b48 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1824ed530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x1824ed020 start_wqthread + 4
com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x1824254d8 kevent_qos + 8
1 libdispatch.dylib 0x1822e87d8 _dispatch_mgr_invoke + 232
2 libdispatch.dylib 0x1822d7648 _dispatch_source_invoke + 50
Thread
0 libsystem_kernel.dylib 0x182424b48 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1824ed530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x1824ed020 start_wqthread + 4
// ... several more threads like the above
RLMRealm notification listener
0 libsystem_kernel.dylib 0x18240d528 kevent + 8
1 Realm 0x10057711c realm::_impl::ExternalCommitHelper::listen() (external_commit_helper.cpp:199)
2 Realm 0x100577318 std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator()() (future:2331)
3 Realm 0x1005772a0 std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute() (future:1025)
4 Realm 0x100577468 std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) (memory:2516)
5 libsystem_pthread.dylib 0x1824efb28 _pthread_body + 156
6 libsystem_pthread.dylib 0x1824efa8c _pthread_body + 154
7 libsystem_pthread.dylib 0x1824ed028 thread_start + 4
com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x182408fd8 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x182408e54 mach_msg + 72
2 CoreFoundation 0x182840ce8 __CFRunLoopServiceMachPort + 196
3 CoreFoundation 0x18283e9ec __CFRunLoopRun + 1032
4 CoreFoundation 0x182768d10 CFRunLoopRunSpecific + 384
5 CFNetwork 0x182ee9af4 +[NSURLConnection(Loader) _resourceLoadLoop:] + 412
6 Foundation 0x18325fe1c __NSThread__start__ + 1000
7 libsystem_pthread.dylib 0x1824efb28 _pthread_body + 156
8 libsystem_pthread.dylib 0x1824efa8c _pthread_body + 154
9 libsystem_pthread.dylib 0x1824ed028 thread_start + 4
NSOperationQueue 0x13eb90310 :: NSOperation 0x13f2986c0 (QOS: LEGACY)
0 libsystem_kernel.dylib 0x18242441c __semwait_signal + 8
1 libsystem_c.dylib 0x18234122c nanosleep + 212
2 libsystem_c.dylib 0x18234114c usleep + 68
3 Starscream 0x1002ef460 WebSocket.((initStreamsWithData in _E91840E7069A0D2D302D042308E9D928)(NSData, Int) -> ()).(closure #1) (WebSocket.swift:313)
4 Foundation 0x183244510 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
5 Foundation 0x183196900 -[NSBlockOperation main] + 96
6 Foundation 0x183186ed8 -[__NSOperationInternal _start:] + 604
7 Foundation 0x183246904 __NSOQSchedule_f + 224
8 libdispatch.dylib 0x1822d547c _dispatch_client_callout + 16
9 libdispatch.dylib 0x1822e14c0 _dispatch_queue_drain + 864
10 libdispatch.dylib 0x1822d8f80 _dispatch_queue_invoke + 464
11 libdispatch.dylib 0x1822e3390 _dispatch_root_queue_drain + 728
12 libdispatch.dylib 0x1822e30b0 _dispatch_worker_thread3 + 112
13 libsystem_pthread.dylib 0x1824ed470 _pthread_wqthread + 1092
14 libsystem_pthread.dylib 0x1824ed020 start_wqthread + 4
I am experiencing it too:
* thread #20: tid = 0x1929, 0x0000000180cb1528 libsystem_kernel.dylib`kevent + 8, name = 'RLMRealm notification listener'
* frame #0: 0x0000000180cb1528 libsystem_kernel.dylib`kevent + 8
frame #1: 0x000000010200a9f8 Realm`realm::_impl::ExternalCommitHelper::listen(this=0x000000012e38bb60) + 412 at external_commit_helper.cpp:199
frame #2: 0x000000010200b5a4 Realm`realm::_impl::ExternalCommitHelper::ExternalCommitHelper(this=0x000000012e3a7170)::$_0::operator()() const + 24 at external_commit_helper.cpp:159
frame #3: 0x000000010200b580 Realm`_ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE [inlined] std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(__f=0x000000012e3a7170)::$_0>(fp)(std::__1::forward<>(fp0))), realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) + 64 at __functional_base:416
frame #4: 0x000000010200b570 Realm`_ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE(this=0x000000012e3a7170, (null)=__tuple_indices<> @ 0x000000016e19ec20) + 48 at future:2338
frame #5: 0x000000010200b534 Realm`std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator(this=0x000000012e3a7170)() + 24 at future:2331
frame #6: 0x000000010200b444 Realm`std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute(this=0x000000012e3a70e0) + 32 at future:1025
frame #7: 0x000000010200bcc8 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] std::__1::__invoke<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*, void>(__f=0x000000012e374d30, __a0=0x000000012e374d40)::$_0> >*>(fp0)).*fp(std::__1::forward<>(fp1))), void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*&&)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*&&) + 100 at __functional_base:383
frame #8: 0x000000010200bc64 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] _ZNSt3__116__thread_executeIMNS_19__async_assoc_stateIvNS_12__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS4_16RealmCoordinatorEE3$_0JEEEEEFvvEJPSA_EJLm1EEEEvRNS_5tupleIJT_DpT0_EEENS_15__tuple_indicesIJXspT1_EEEE(__t=0x000000012e374d30) + 40 at thread:337
frame #9: 0x000000010200bc3c Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(__vp=0x000000012e374d30) + 248 at thread:347
frame #10: 0x0000000180d93b28 libsystem_pthread.dylib`_pthread_body + 156
frame #11: 0x0000000180d93a8c libsystem_pthread.dylib`_pthread_start + 156
frame #12: 0x0000000180d91028 libsystem_pthread.dylib`thread_start + 4
@ptseng can you share a project that triggers the crash? Thanks!
@jpsim I was able to reliably reproduce the crash referenced in #3510, although I am not sure if it is the same crash as in this thread.
boom.zip (read the README)
Basically: the entire database (the memory mapping) is yanked out from under Realm by the system if the file protection mode is NSFileProtectionModeComplete when the device is locked such that Realm appears to crash in the next operation it attempts.
EDIT: Test device must have a passcode set
Thanks for taking the time to craft a repro case @conradev! We'll need to discuss internally to figure out how we can mitigate this, if it's at all possible...
I am not sure if it is the same crash as in this thread.
I actually just experienced the crash with the trace including realm::SharedGroup::advance_read and it occurred when my device was unlocked, but sitting idle for a few minutes. I do think the reproduction case and the issue in this thread are separate.
Wanted to note that I've also separately noticed this crash (with the exception named "Realm::LogicError: bad version") occur on a device that was running our app idle in the foreground for a few minutes.
The issue also appears to be fairly common among our beta testers (we have received many crash reports for this issue) and apparently only began occurring after we upgraded from Realm 0.95.1 to 0.98.6.
Any update?
Actually I got the exception quite often, over 50% my app's crash was occurred by this exception. But when I got the exception, my app is doing lots of heavy reading and write operations in a 'Sync' action, that I
can't simply reproduce the issue. :(
I haven't had any luck with just auditing the code and looking for problems, so it's unlikely that we'll be able to make progress on fixing this without a repro case of some sort.
FWIW I have a strong feeling this bug is caused by running realm.refresh() within a Realm notification block and/or write transaction. Working on a project to repro.
Calling it from within a write transaction is explicitly a no-op, but refreshing from within a notification if there are still more notifications to be delivered could plausibly cause this.
I dug into this a bit more, and while I think calling refresh() from within a notification block should probably be forbidden (it behaves somewhat oddly and is very unlikely to be a useful thing to do), I couldn't find any way to get it to actually break.
Just to be clear, we have yet to identify the root cause here, or find a repro case, so if anyone could share a sample project if they manage to create one, that'd be greatly appreciated, and basically a requirement for us to make progress on this.
Hi guys,
I'm experiencing the same crash once in a while. I'm still investigating what could cause it, our application performs some transactions in a background thread, basically it queries dirty objects and post them to an API endpoint.
I started to get the exception in a more complex view that keeps track of changes in the main UI only. I was using RBQFetchedResultsController for fetching some records, and decided to give it a try only relying on Realm notifications and stopped getting those exceptions. I went back to a view that is still using this extension, RBQFetchedResultsController, and it still happens there.
The exception is always being thrown at this block, but acctually is very difficult to debug for me.
I'm in the middle of a critical deadline so I haven't got the time to set up a project to replicate my situation exactly but I will hopefully be able in a couple of days.
I am able to recreate this pretty reliably in v2.0.1. It _seems_ more frequent than in 1.0.2, but it is hard to say.
I have a background thread that sync objects to a server and then updates realm. This happens in a dedicated dispatch queue. I call [[RLMRealm defaultRealm] refresh] before each iteration through the syncing logic (happens once a second).
There is a UITableView that has a notification block on a RLMResults that is supposed to process the data and update the table.
Sometimes it crashes! Here's a stack trace. Let me know if there is more data I can provide.
Thread 1
Queue : com.apple.main-thread (serial)
#0 0x000000010a308867 in __cxa_throw ()
#1 0x0000000105c953b7 in std::__1::unique_ptr<realm::TableView, std::__1::default_delete<realm::TableView> > realm::SharedGroup::import_from_handover<realm::TableView>(std::__1::unique_ptr<realm::SharedGroup::Handover<realm::TableView>, std::__1::default_delete<realm::SharedGroup::Handover<realm::TableView> > >) at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/core/include/realm/group_shared.hpp:900
#2 0x0000000105c951d7 in realm::_impl::ResultsNotifier::deliver(realm::SharedGroup&) at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/impl/results_notifier.cpp:193
#3 0x0000000105c89d98 in realm::_impl::RealmCoordinator::advance_to_ready(realm::Realm&) at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/impl/realm_coordinator.cpp:585
#4 0x0000000105c7a065 in realm::_impl::WeakRealmNotifier::Callback::operator()() at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/impl/weak_realm_notifier.cpp:40
#5 0x00000001082e9311 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#6 0x00000001082ce59c in __CFRunLoopDoSources0 ()
#7 0x00000001082cda86 in __CFRunLoopRun ()
#8 0x00000001082cd494 in CFRunLoopRunSpecific ()
#9 0x000000010d34da6f in GSEventRunModal ()
#10 0x000000010abb8f34 in UIApplicationMain ()
#11 0x0000000104d92c5f in main at /Users/jesset/projects/crm/CRM-XM/main.m:14
#12 0x000000010aa0c68d in start ()
#13 0x000000010aa0c68d in start ()
Thread 5
com.apple.uikit.eventfetch-thread (6)
Thread 13
Queue : com.apple.root.default-qos.overcommit (concurrent)
#0 0x000000010c95189b in pthread_mutex_unlock ()
#1 0x00000001082f7729 in CFRunLoopSourceInvalidate ()
#2 0x0000000105c7a2da in realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback>::~EventLoopSignal() at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/util/apple/event_loop_signal.hpp:58
#3 0x0000000105bcee7e in std::__1::__shared_weak_count::__release_shared() ()
#4 0x0000000105c7a017 in std::__1::shared_ptr<realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback> >::~shared_ptr() [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4593
#5 0x0000000105c7a009 in std::__1::shared_ptr<realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback> >::~shared_ptr() [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4591
#6 0x0000000105c7a009 in realm::_impl::WeakRealmNotifier::~WeakRealmNotifier() at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/impl/weak_realm_notifier.cpp:35
#7 0x0000000105c8818f in std::__1::allocator<realm::_impl::WeakRealmNotifier>::destroy(realm::_impl::WeakRealmNotifier*) [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1795
#8 0x0000000105c88187 in void std::__1::allocator_traits<std::__1::allocator<realm::_impl::WeakRealmNotifier> >::__destroy<realm::_impl::WeakRealmNotifier>(std::__1::integral_constant<bool, true>, std::__1::allocator<realm::_impl::WeakRealmNotifier>&, realm::_impl::WeakRealmNotifier*) [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1668
#9 0x0000000105c88187 in void std::__1::allocator_traits<std::__1::allocator<realm::_impl::WeakRealmNotifier> >::destroy<realm::_impl::WeakRealmNotifier>(std::__1::allocator<realm::_impl::WeakRealmNotifier>&, realm::_impl::WeakRealmNotifier*) [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1536
#10 0x0000000105c88187 in std::__1::__vector_base<realm::_impl::WeakRealmNotifier, std::__1::allocator<realm::_impl::WeakRealmNotifier> >::__destruct_at_end(realm::_impl::WeakRealmNotifier*) [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:424
#11 0x0000000105c8817e in std::__1::vector<realm::_impl::WeakRealmNotifier, std::__1::allocator<realm::_impl::WeakRealmNotifier> >::__destruct_at_end(realm::_impl::WeakRealmNotifier*) [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:813
#12 0x0000000105c8817e in std::__1::vector<realm::_impl::WeakRealmNotifier, std::__1::allocator<realm::_impl::WeakRealmNotifier> >::erase(std::__1::__wrap_iter<realm::_impl::WeakRealmNotifier const*>, std::__1::__wrap_iter<realm::_impl::WeakRealmNotifier const*>) at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:1696
#13 0x0000000105c88087 in realm::_impl::RealmCoordinator::unregister_realm(realm::Realm*) at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/impl/realm_coordinator.cpp:172
#14 0x0000000105d44693 in realm::Realm::~Realm() at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/shared_realm.cpp:202
#15 0x0000000105bcee7e in std::__1::__shared_weak_count::__release_shared() ()
#16 0x0000000107144a0a in object_cxxDestructFromClass(objc_object*, objc_class*) ()
#17 0x00000001071504de in objc_destructInstance ()
#18 0x0000000107150510 in object_dispose ()
#19 0x0000000105d2a966 in -[RLMRealm dealloc] at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/RLMRealm.mm:520
#20 0x000000010715ab12 in objc_object::sidetable_release(bool) ()
#21 0x000000010715b1d1 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#22 0x000000010a9a1800 in _dispatch_root_queue_drain ()
#23 0x000000010a9a108b in _dispatch_worker_thread3 ()
#24 0x000000010c953746 in _pthread_wqthread ()
#25 0x000000010c953221 in start_wqthread ()
com.apple.NSURLConnectionLoader (8)Thread 9Thread 10Thread 11Thread 12RLMRealm notification listener (15)#0 0x000000010c91fe2e in kevent ()
#1 0x0000000105c73c6a in realm::_impl::ExternalCommitHelper::listen() at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/impl/apple/external_commit_helper.cpp:199
#2 0x0000000105c7470e in realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0::operator()() const [inlined] at /Users/realm/workspace/create_github_release_cocoa/realm-cocoa/Realm/ObjectStore/src/impl/apple/external_commit_helper.cpp:159
#3 0x0000000105c74709 in std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(decltype(std::__1::forward<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(fp)(std::__1::forward<>(fp0))), realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:416
#4 0x0000000105c74700 in _ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:2348
#5 0x0000000105c74700 in std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator()() at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:2341
#6 0x0000000105c7469a in std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute() at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1031
#7 0x0000000105c74843 in std::__1::__invoke<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*, void>(decltype(*(std::__1::forward<std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*>(fp0)).*fp(std::__1::forward<>(fp1))), void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*&&)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*&&) [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:383
#8 0x0000000105c7482a in _ZNSt3__116__thread_executeIMNS_19__async_assoc_stateIvNS_12__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS4_16RealmCoordinatorEE3$_0JEEEEEFvvEJPSA_EJLm1EEEEvRNS_5tupleIJT_DpT0_EEENS_15__tuple_indicesIJXspT1_EEEE [inlined] at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:347
#9 0x0000000105c7482a in std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) at /Applications/Xcode-8.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:357
#10 0x000000010c953abb in _pthread_body ()
#11 0x000000010c953a07 in _pthread_start ()
#12 0x000000010c953231 in thread_start ()
Looks like my issue is fixed in 2.02. I guess it is this release note "Fix a BadVersion error when a background worker finishes running while older results from that worker are being delivered to a different thread."
I'm glad to hear that @asjesset!
Can others on this thread confirm whether or not 2.0.2 also resolved this problem for you?
@jpsim I'm sorry to bring bad news, but we have been seeing this since the upgrade from 1.0.2 to 1.1.0 and above. I have, however, managed to create a sample project reproducing this issue, and I have emailed it to [email protected].
In short, the problem (for us) seems to be related to an NSURLSession dispatching the delegate methods on the .mainQueue() if supplied on session creation.
When we then write download progress to Realm in func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64...) and at the same time listen for changes via a notification block for a results set on the same queue, the BadVersion error almost* always occurs.
_* for one file download it sometimes work, but for two concurrent downloads, it always crashes._
I'm really not sure why this would happen. Perhaps we missed some part of the Realm documentation stating we should not do this the way we do, but hopefully this sample project can help you guys figure out what might render this.
Thanks for reporting and sharing a very good repro case @hermanolsson! We were able to reproduce the race on our end and @tgoyne has already pushed a fix in realm/realm-object-store#195. We'll close this issue once that fix has been included in this repo, at which point it would be useful if you could try it out in your main app where you've been experiencing this problem.
@jpsim do you have any idea about the timeframe for the fix to be merged here? We're having this crash in production and are preparing a fix version. Would love to include this in the fix since it is one of our top issues. Thanks a lot.
@jpsim @tgoyne is there a way to test this? We are seeing this crash a lot right now and I would like to send a version to our beta testers to validate the fix. Thanks.
@kevincador you can test this by building from the master branch. If you're using CocoaPods, specify the following in your Podfile:
pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
_EDIT: changed jp-update-object-store to master branch since #4234 was just merged._
Please reopen if you still see this problem after incorporating realm/realm-object-store#195 into your apps.
Thank you @jpsim ! I have integrated master into our project and I have not seen this crash since. 馃憤
@jpsim did a lot of testing in local. So far, so good. Will send a new version to our beta testers soon and get back to you asap if we see the issue again.
I confirm we're not seeing this crash anymore (public beta testing). Will send this to production soon.
Is this bug present version 2.0.2? Or there haven't been any new releases recently?
The change from realm/realm-object-store#195 has not yet been included in a release. We're working on getting a release out later this week, as soon as we've updated our infrastructure and release process to produce builds for Swift 3.0.1.
@jpsim We're debating downgrading to 1.0.2 while waiting for this issue to be fixed. Does this sound like a good strategy to you, or would it be better to wait for the update?
Realm 2.0.3 should be out by end of day tomorrow (hopefully earlier).
I experienced the bug in v2.1, but due to it's random nature I really don't know how to help you figure this out... The only thing to comes to my mind, given it happened while AppDelegate was running, it could happen during the database migration.
Here's the code:
func migrateRealm() {
let config = Realm.Configuration(
schemaVersion: 6,
migrationBlock: { migration, oldSchemaVersion in
if (oldSchemaVersion < 1) {
// Nothing to do!
}
if (oldSchemaVersion < 2) {
var helpers: Int = 0
migration.enumerateObjects(ofType: Game.className(), { oldObject, newObject in
helpers = oldObject!["helpers"] as! Int
})
migration.enumerateObjects(ofType: Stats.className()) { oldObject, newObject in
newObject!["numberOfRestarts"] = helpers
}
}
if (oldSchemaVersion < 3) {
// Nothing to do!
}
if (oldSchemaVersion < 4) {
migration.enumerateObjects(ofType: User.className(), { oldObject, newObject in
newObject!["removedAds"] = false
})
migration.enumerateObjects(ofType: Stats.className()) { oldObject, newObject in
newObject!["gameVersion"] = 1.3
}
}
if (oldSchemaVersion < 5) {
// nothing to do?
}
if (oldSchemaVersion < 6) {
migration.enumerateObjects(ofType: Game.className(), { (oldObject, newObject) in
newObject!["level"] = 1
newObject!["experiencePoints"] = 0
newObject!["skillPoints"] = 0
})
migration.enumerateObjects(ofType: User.className(), { (oldObject, newObject) in
newObject!["caughtCheating"] = false
})
}
})
Realm.Configuration.defaultConfiguration = config
_ = try! Realm()
}
@pawelkata since your issue appears to be occurring during a migration of a Realm rather than when delivering collection notifications, it's likely to be unrelated to the rest of the discussion in this thread.
However, I'd encourage you to update to the latest version of Realm and open a _new_ issue along with more information if you run into problems. Thanks.
I'll be locking this conversation to make sure future problems are reported as new issues, preventing messages from being missed by our team. Thanks for understanding!
Most helpful comment
@jpsim We're debating downgrading to 1.0.2 while waiting for this issue to be fixed. Does this sound like a good strategy to you, or would it be better to wait for the update?