couchbase / couchbase-lite-ios

Lightweight, embedded, syncable NoSQL database engine for iOS and MacOS apps.
Apache License 2.0
1.62k stars 297 forks source link

'LiteCore Timer', stop reason = EXC_BAD_ACCESS in mobile-training-todo #2072

Closed tleyden closed 6 years ago

tleyden commented 6 years ago

Steps to repro

  1. Download couchbase-lite-swift_community_2.0.0-620.zip from latestbuilds
  2. Extract in mobile-training-todo/swift/frameworks
  3. Enable replication and login via let kLoginFlowEnabled = true and let kSyncEnabled = true
  4. Run Sync Gateway commit https://github.com/couchbase/sync_gateway/commit/fb8dddcb7db2d5d2b3b6052729b9fdefde00443c with this config
  5. Run mobile-training-todo commit 74359459fb419609756fd0007288f83b4b426e5e (feature/2.0) branch
  6. I added a list and an item with the photo
  7. Leave it idle for one hour or so
  8. Run the mobile-training-todo Android app and share a list with the user logged into the ios mobile-training-todo
  9. When I switched back the ios mobile-training-todo to see if the list was shared, the app was frozen and I could see that it hit an EXC_BAD_ACCESS

Backtrace

(lldb) bt
* thread #11, name = 'LiteCore Timer', stop reason = EXC_BAD_ACCESS (code=1, address=0x38)
  * frame #0: 0x0000000102a17cd8 CouchbaseLiteSwift`litecore::actor::Timer::Manager::setFireTime(litecore::actor::Timer*, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) [inlined] std::__1::__atomic_base<litecore::actor::Timer::state, false>::load(this=0x0000000000000038, __m=memory_order_seq_cst) const at atomic:893 [opt]
    frame #1: 0x0000000102a17cd8 CouchbaseLiteSwift`litecore::actor::Timer::Manager::setFireTime(litecore::actor::Timer*, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) [inlined] std::__1::__atomic_base<litecore::actor::Timer::state, false>::operator litecore::actor::Timer::state(this=0x0000000000000038) const at atomic:897 [opt]
    frame #2: 0x0000000102a17cd8 CouchbaseLiteSwift`litecore::actor::Timer::Manager::setFireTime(litecore::actor::Timer*, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) [inlined] litecore::actor::Timer::Manager::_unschedule(this=0x000060c000111b80, timer=0x0000000000000000) at Timer.cc:90 [opt]
    frame #3: 0x0000000102a17cd8 CouchbaseLiteSwift`litecore::actor::Timer::Manager::setFireTime(this=0x000060c000111b80, timer=0x0000000000000000, when=<unavailable>) at Timer.cc:116 [opt]
    frame #4: 0x0000000102a1b7e8 CouchbaseLiteSwift`litecore::websocket::WebSocketImpl::sendPing() [inlined] litecore::actor::Timer::fireAfter(this=<unavailable>) at Timer.hh:63 [opt]
    frame #5: 0x0000000102a1b7ca CouchbaseLiteSwift`litecore::websocket::WebSocketImpl::sendPing() [inlined] litecore::websocket::WebSocketImpl::schedulePing() at WebSocketImpl.cc:292 [opt]
    frame #6: 0x0000000102a1b7ca CouchbaseLiteSwift`litecore::websocket::WebSocketImpl::sendPing(this=0x00007f7ee8002240) at WebSocketImpl.cc:303 [opt]
    frame #7: 0x0000000102a17963 CouchbaseLiteSwift`litecore::actor::Timer::Manager::run() [inlined] std::__1::function<void ()>::operator(this=<unavailable>)() const at functional:1911 [opt]
    frame #8: 0x0000000102a17954 CouchbaseLiteSwift`litecore::actor::Timer::Manager::run(this=0x000060c000111b80) at Timer.cc:63 [opt]
    frame #9: 0x0000000102a177dd CouchbaseLiteSwift`std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, litecore::actor::Timer::Manager::Manager()::$_0> >(void*, void*) [inlined] litecore::actor::Timer::Manager::Manager()::$_0::operator()() const at Timer.cc:33 [opt]
    frame #10: 0x0000000102a177d8 CouchbaseLiteSwift`std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, litecore::actor::Timer::Manager::Manager()::$_0> >(void*, void*) [inlined] std::__1::__invoke<litecore::actor::Timer::Manager::Manager()::$_0>(decltype(std::__1::forward<litecore::actor::Timer::Manager::Manager()::$_0>(fp)(std::__1::forward<>(fp0))), litecore::actor::Timer::Manager::Manager()::$_0&&) at type_traits:4291 [opt]
    frame #11: 0x0000000102a177d8 CouchbaseLiteSwift`std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, litecore::actor::Timer::Manager::Manager()::$_0> >(void*, void*) [inlined] _ZNSt3__116__thread_executeINS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEZN8litecore5actor5Timer7ManagerC1EvE3$_0JEJEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE(__t=<unavailable>) at thread:336 [opt]
    frame #12: 0x0000000102a177d8 CouchbaseLiteSwift`std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, litecore::actor::Timer::Manager::Manager()::$_0> >(__vp=0x000060c0002085f0) at thread:346 [opt]
    frame #13: 0x00000001084046c1 libsystem_pthread.dylib`_pthread_body + 340
    frame #14: 0x000000010840456d libsystem_pthread.dylib`_pthread_start + 377
    frame #15: 0x0000000108403c5d libsystem_pthread.dylib`thread_start + 13
(lldb) 

Thread stacks: https://gist.github.com/tleyden/e90791bab81d23fd8b997ca0afbb4bb4

Full mobile-training-todo client side logs

https://gist.github.com/tleyden/e39ab2ffac08323c267fe5c9a51f9dbc#file-mobile_training_todo-txt

Sporadic vs reproducible

tleyden commented 6 years ago

I just ran into this again.

In this case, my ios/xcode app had been idling for several days (and been offline several times), and when I switched back to it, it had hit the issue

snej commented 6 years ago

This is a LiteCore issue, looks like (note litecore:: in the backtrace...)

tleyden commented 6 years ago

Moved to https://github.com/couchbase/couchbase-lite-core/issues/428