Crash on iOS with assertion failing on !_changeTracker


Using couchbase lite 1.2.1 for iOS we are seeing an assertion failure recorded on crashlytics with the following stack on a thread named CouchbaseLite.

Fatal Exception: NSInternalInconsistencyException !_changeTracker

15 Concepts                       0x1005e0c9c _AssertFailed + 470248
16 Concepts                       0x100589880 -[CBLRestPuller startChangeTracker] + 112844
17 Concepts                       0x100589304 -[CBLRestPuller beginReplicating] + 111440
18 Concepts                       0x100588530 __45-[CBLRestReplicator fetchRemoteCheckpointDoc]_block_invoke + 107900
19 Concepts                       0x100587adc __61-[CBLRestReplicator sendAsyncRequest:path:body:onCompletion:]_block_invoke + 105256
20 Concepts                       0x10059ab38 -[CBLRemoteRequest respondWithResult:error:] + 183172
21 Concepts                       0x10059c1ec -[CBLRemoteJSONRequest connectionDidFinishLoading:] + 188984
22 CFNetwork                      0x18231d6a0 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 80
23 CFNetwork                      0x18231d630 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 200
24 CFNetwork                      0x18231d7a4 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 56
25 CFNetwork                      0x18218339c ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 100
26 CFNetwork                      0x18227741c ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 108
27 libdispatch.dylib              0x1815ed47c _dispatch_client_callout + 16
28 libdispatch.dylib              0x1815f67b8 _dispatch_block_invoke + 540
29 CFNetwork                      0x18216fac0 RunloopBlockContext::_invoke_block(void const*, void*) + 36

This issue looks similar except there are no symbols there…

That issue is closed with the enigmatic “found the problem, it has to do with how we use CBL with GCD.”

I would appreciate any ideas on what we might be doing wrong with GCD to cause this?


I don’t know any more about that comment either; it sounds like they had a thread-safety problem in their app code?


Please post your backtrace to the Github issue and I’ll reopen it.


Thanks, that’s done!


We are facing the issue in version 1.4 now. Please see the logs

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '!_changeTracker'

Last Exception Backtrace:
CoreFoundation                 0x00000001d7d8dea4 __exceptionPreprocess + 228
libobjc.A.dylib                0x00000001d6f5da4c objc_exception_throw + 52
CoreFoundation                 0x00000001d7ca3a28 +[NSException raise:format:arguments:] + 100
Foundation                     0x00000001d87e097c -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 84
Construct                      0x0000000104dbcd9c _AssertFailed (Test_Assertions.m:31)
Construct                      0x0000000104d59028 -[CBLRestPuller startChangeTracker] (CBLRestPuller.m:100)
Construct                      0x0000000104d58a9c -[CBLRestPuller beginReplicating] (CBLRestPuller.m:94)
Construct                      0x0000000104d57d08 __45-[CBLRestReplicator fetchRemoteCheckpointDoc]_block_invoke (CBLRestReplicator.m:774)
Construct                      0x0000000104d6fa68 -[CBLRemoteRequest respondWithResult:error:] (CBLRemoteRequest.m:191)
Construct                      0x0000000104d71708 -[CBLRemoteJSONRequest didFinishLoading] (CBLRemoteRequest.m:599)
Construct                      0x0000000104d9d320 __57-[CBLRemoteSession URLSession:task:didCompleteWithError:]_block_invoke (CBLRemoteSession.m:333)
Foundation                     0x00000001d8841428 __NSThreadPerformPerform + 332
CoreFoundation                 0x00000001d7d1e0dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
CoreFoundation                 0x00000001d7d1e05c __CFRunLoopDoSource0 + 84
CoreFoundation                 0x00000001d7d1d940 __CFRunLoopDoSources0 + 172
CoreFoundation                 0x00000001d7d1880c __CFRunLoopRun + 1036
CoreFoundation                 0x00000001d7d180dc CFRunLoopRunSpecific + 432
Foundation                     0x00000001d870e490 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 296
Construct                      0x0000000104d534ec -[CBL_RunLoopServer runServerThread] (CBL_Server.m:193)
Foundation                     0x00000001d8841238 __NSThread__start__ + 1036
libsystem_pthread.dylib        0x00000001d79a8258 _pthread_body + 124
libsystem_pthread.dylib        0x00000001d79a81b8 _pthread_start + 44
libsystem_pthread.dylib        0x00000001d79abcf0 thread_start + 0


None of us are very familiar with 1.4 anymore, I’m afraid, even those of us who wrote the code that’s failing here. That release is ending its support period soon, too. If you’re an enterprise customer, you should file a support request.

Was anything logged before the exception? What if you turn on SyncVerbose and ChangeTracker logging?
What are the circumstances that this happened in? Is it reproducible?