Fleece crash during document retrieval

Couchbase Lite crashes sporadically in production. Crashes occur when retrieving multiple docs inside a loop, the docs are all the same type.

Is this a multithreading issue on my side? Do I have to ensure that cblite is always accessed from the same thread, or is that an old restriction?

Excerpt from crash log:

9   libc++abi.dylib                      0x0000000199762f58 std::__terminate(void (*)()) + 16
10  libc++abi.dylib                      0x0000000199762ef4 std::terminate() + 60
11  CouchbaseLiteSwift                   0x00000001019caa94 fleece::MDict<objc_object* __strong>::get+ 1501844 (fleece::slice) const + 80
12  CouchbaseLiteSwift                   0x00000001019ca9e8 _get+ 1501672 (fleece::MDict<objc_object* __strong>&, NSString*) + 56
13  CouchbaseLiteSwift                   0x00000001019cab24 _getObject+ 1501988 (fleece::MDict<objc_object* __strong>&, NSString*, objc_class*) + 48
14  CouchbaseLiteSwift                   0x00000001019c88b0 -[CBLDictionary valueForKey:] + 72
15  CouchbaseLiteSwift                   0x00000001018724d8 DictionaryObject.toDictionary+ 91352 () + 296
16  CouchbaseLiteSwift                   0x0000000101872584 DictionaryObject.toDictionary+ 91524 () + 468
17  CouchbaseLiteSwift                   0x000000010187a354 ArrayObject.toArray+ 123732 () + 388
18  CouchbaseLiteSwift                   0x0000000101872690 DictionaryObject.toDictionary+ 91792 () + 736
19  CouchbaseLiteSwift                   0x000000010187a354 ArrayObject.toArray+ 123732 () + 388
20  CouchbaseLiteSwift                   0x0000000101872690 DictionaryObject.toDictionary+ 91792 () + 736
21  CouchbaseLiteSwift                   0x000000010187a354 ArrayObject.toArray+ 123732 () + 388
22  CouchbaseLiteSwift                   0x0000000101884ca4 Document.toDictionary+ 167076 () + 740
23  MyApp                                0x0000000100b04c00 MyApp.myFunctionThatRetrievesASetOfDocs() -> [MyApp.Doc]
  • Device: iPhone 11 Pro Max, iPhone 7
  • iOS: 15.2.1, 15.1
  • CouchbaseLiteSwift 2.8.4

I’m not that familiar with symbolication of iOS stuff but I think this stack trace needs some pairing with symbols because the large offsets from the symbols effectively mean that where this actually happened is in a much different place but the crash logger couldn’t find any function names in the symbols nearby.

Thanks for the thought, but I have several other crash reports that are essentially the same and they don’t have these large offsets. I suspect the offsets are an artifact of symbolicating the crash inside Xcode rather than HockeyApp. The latter looks normal … see below.

11  CouchbaseLiteSwift                   0x000000010112ea94 fleece::MDict<objc_object* __strong>::get(fleece::slice) const (Fleece.cc:253)
12  CouchbaseLiteSwift                   0x000000010112e9e8 _get(fleece::MDict<objc_object* __strong>&, NSString*) (CBLDictionary.mm:132)
13  CouchbaseLiteSwift                   0x000000010112eb24 _getObject(fleece::MDict<objc_object* __strong>&, NSString*, objc_class*) (CBLDictionary.mm:137)
14  CouchbaseLiteSwift                   0x000000010112c8b0 -[CBLDictionary valueForKey:] (CBLDictionary.mm:147)
15  CouchbaseLiteSwift                   0x0000000100fd64d8 CouchbaseLiteSwift.DictionaryObject.toDictionary() -> [Swift.String : Any] (DictionaryObject.swift:81)
16  CouchbaseLiteSwift                   0x0000000100fd6584 CouchbaseLiteSwift.DictionaryObject.toDictionary() -> [Swift.String : Any] (DictionaryObject.swift:215)
17  CouchbaseLiteSwift                   0x0000000100fde354 CouchbaseLiteSwift.ArrayObject.toArray() -> [Any] (ArrayObject.swift:192)
18  CouchbaseLiteSwift                   0x0000000100fd6690 CouchbaseLiteSwift.DictionaryObject.toDictionary() -> [Swift.String : Any] (DictionaryObject.swift:217)
19  CouchbaseLiteSwift                   0x0000000100fde354 CouchbaseLiteSwift.ArrayObject.toArray() -> [Any] (ArrayObject.swift:192)
20  CouchbaseLiteSwift                   0x0000000100fd6690 CouchbaseLiteSwift.DictionaryObject.toDictionary() -> [Swift.String : Any] (DictionaryObject.swift:217)
21  CouchbaseLiteSwift                   0x0000000100fde354 CouchbaseLiteSwift.ArrayObject.toArray() -> [Any] (ArrayObject.swift:192)
22  CouchbaseLiteSwift                   0x0000000100fe8ca4 CouchbaseLiteSwift.Document.toDictionary() -> [Swift.String : Any] (Document.swift:208)

@philmitchell is it possible to share the full crash log with us?

Current trace only shows the thread just std::terminate() after accessing the FLDict_Get(FLString).