SIGABRT (#0): Application crash: SIGABRT (Abort trap)

I am saving the document
`let result = try database.defaultCollection().save(document: document, concurrencyControl: .failOnConflict)`

then got crash. I have no clue which cause this crash. Please help
> 
> 0   libsystem_kernel.dylib              0x00000001e3040200 __pthread_kill + 8
> 1   libsystem_c.dylib                   0x00000001ada75c8c abort + 180
> 2   libc++abi.dylib                     0x00000001f33e2b8c __cxxabiv1::__aligned_malloc_with_fallback(unsigned long) + 0
> 3   libc++abi.dylib                     0x00000001f33d2a68 demangling_terminate_handler() + 312
> 4   libobjc.A.dylib                     0x000000019f775d4c _objc_terminate() + 160
> 5   CouchbaseLiteSwift                  0x0000000104d7eb68 fleece::Backtrace::installTerminateHandler(std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>)::$_1::operator()() const::{lambda()#1}::operator()() const + 112 (Backtrace.cc:414)
> 6   CouchbaseLiteSwift                  0x0000000104d7eaf8 fleece::Backtrace::installTerminateHandler(std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>)::$_1::operator()() const::{lambda()#1}::operator()() const + 0 (Backtrace.cc:400)
> 7   libc++abi.dylib                     0x00000001f33e1f28 std::__terminate(void (*)()) + 20
> 8   libc++abi.dylib                     0x00000001f33e1ec4 std::terminate() + 56
> 9   CouchbaseLiteSwift                  0x0000000104c33a78 fleece::Retained<litecore::C4QueryEnumeratorImpl>::~Retained() + 0 (vendor/fleece/API/fleece/RefCounted.hh:109)
> 10  CouchbaseLiteSwift                  0x0000000104c33a78 fleece::Retained<litecore::C4QueryEnumeratorImpl>::~Retained() + 0
> 11  CouchbaseLiteSwift                  0x0000000104c33a78 C4Query::notifyObservers(std::__1::set<litecore::C4QueryObserverImpl*, std::__1::less<litecore::C4QueryObserverImpl*>, std::__1::allocator<litecore::C4QueryObserverImpl*> > const&, litecore::QueryEnumerator*, C4Error) + 124 (C/c4Query.cc:327)
> 12  CouchbaseLiteSwift                  0x0000000104c33f78 C4Query::liveQuerierUpdated(litecore::QueryEnumerator*, C4Error) + 108 (C/c4Query.cc:309)
> 13  CouchbaseLiteSwift                  0x0000000104c88414 fleece::Retained<litecore::QueryEnumerator>::~Retained() + 0 (vendor/fleece/API/fleece/RefCounted.hh:109)
> 14  CouchbaseLiteSwift                  0x0000000104c88414 fleece::Retained<litecore::QueryEnumerator>::~Retained() + 0
> 15  CouchbaseLiteSwift                  0x0000000104c88414 litecore::LiveQuerier::_runQuery(litecore::Query::Options) + 468 (LiteCore/Database/LiveQuerier.cc:209)
> 16  CouchbaseLiteSwift                  0x0000000104c888ac invocation function for block in litecore::actor::Actor::enqueue<litecore::LiveQuerier, litecore::Query::Options>(char const*, void (litecore::LiveQuerier::*)(litecore::Query::Options), litecore::Query::Options) + 60
> 17  CouchbaseLiteSwift                  0x0000000104c23e70 litecore::actor::GCDMailbox::safelyCall(void () block_pointer) const + 28 (LiteCore/Support/GCDMailbox.cc:94)
> 18  CouchbaseLiteSwift                  0x0000000104c23f2c invocation function for block in litecore::actor::GCDMailbox::enqueue(char const*, void () block_pointer) + 16 (LiteCore/Support/GCDMailbox.cc:117)
> 19  libdispatch.dylib                   0x00000001ada104b4 _dispatch_call_block_and_release + 32
> 20  libdispatch.dylib                   0x00000001ada11fdc _dispatch_client_callout + 20
> 21  libdispatch.dylib                   0x00000001ada19694 _dispatch_lane_serial_drain + 672
> 22  libdispatch.dylib                   0x00000001ada1a1e0 _dispatch_lane_invoke + 384

I don’t either.

If you were, for instance, to include the version of Couchbase Lite you were using, what platform you were running on, and some logs of what lead to the error, though, I might be able to figure it out.

The crash happened in Live Query. I suspected that the crash was caused by the live query was trying to post notification to the already-deleted query’s observer. However, it’s a bit weird that it crashed in the RefCounted’s release() function.

Do you happen to remove query’s change listener nor release Query object at the same time when saving a document? It would be very helpful if you have the steps to repro this or CBL verbose logs.

Hi @pasin
I’m too getting following same issue on my iOS app. Using couchbase latest version i.e., 3.1.6

> 5   CouchbaseLiteSwift                  0x0000000104d7eb68 fleece::Backtrace::installTerminateHandler(std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>)::$_1::operator()() const::{lambda()#1}::operator()() const + 112 (Backtrace.cc:414)
> 6   CouchbaseLiteSwift                  0x0000000104d7eaf8 fleece::Backtrace::installTerminateHandler(std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>)::$_1::operator()() const::{lambda()#1}::operator()() const + 0 (Backtrace.cc:400)

Could you please help in this.

@dotri84 are you able to resolve this issue?

Hi @pasin, @dotri84
Any updates, please let me know - We are blocked due to this.

@Techie_iOS It’s not possible to know with only that stacktrace what the issue you are having now. Can you provide the crash log with full stacktrace? Basically, we need more info.

BTW, we have identified and fixed a LiveQuery issue that could cause a crash when removing the token and notifying change happen at the same time. The fix is in release/3.1 brach in couchbase-lite-ios Github repo. We will release the fix in 3.1.7 release which may be out in a month or so (but timeline may be changed due to priority).