Skip to content

Crash on reset for nextBatchID by assert in FSTLevelDBMutationQueue.start #2237

Closed
@shosokawa

Description

@shosokawa

Describe your environment

  • Xcode version: Version 10.1 (10B61)
  • Firebase SDK version: 5.15.0
  • Firebase Component: Firestore
  • Component version: 0.16.1

Describe the problem

An app on a certain device was crashed by HARD_ASSERT in this code repeatedly. I couldn't find a way to handle or recover this error except uninstalling the app once to delete persistent data.

metadata.lastAcknowledgedBatchId = kFSTBatchIDUnknown;
} else {
BatchId lastAcked = metadata.lastAcknowledgedBatchId;
if (lastAcked >= nextBatchID) {
HARD_ASSERT([self isEmpty], "Reset nextBatchID is only possible when the queue is empty");
lastAcked = kFSTBatchIDUnknown;
metadata.lastAcknowledgedBatchId = lastAcked;
_db.currentTransaction->Put([self keyForCurrentMutationQueue], metadata);
}
}

I'm not sure why data was stored like that. Although I suppose that there might be chances as requirement to reset nextBatchID with isEmpty == false.

Steps to reproduce:

I couldn't find a way to create same situation.

Stack trace for the crash:

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x196a90ec4 __exceptionPreprocess
1  libobjc.A.dylib                0x195c61a40 objc_exception_throw
2  CoreFoundation                 0x1969a6b3c +[_CFXNotificationTokenRegistration keyCallbacks]
3  Foundation                     0x1974e3980 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:]
4  Alpaca                         0x104a548d0 firebase::firestore::util::internal::Fail(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (hard_assert_apple.mm:34)
5  Alpaca                         0x104a549e0 firebase::firestore::util::internal::Fail(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) (hard_assert_apple.mm:54)
6  Alpaca                         0x1049f370c -[FSTLevelDBMutationQueue start] (FSTLevelDBMutationQueue.mm:133)
7  Alpaca                         0x104a01320 -[FSTLocalStore startMutationQueue] (FSTLocalStore.mm:124)
8  Alpaca                         0x104a011e4 -[FSTLocalStore start] (FSTLocalStore.mm:119)
9  Alpaca                         0x1049e7720 -[FSTFirestoreClient initializeWithUser:settings:] (FSTFirestoreClient.mm:245)
10 Alpaca                         0x1049e97ec std::__1::__function::__func<-[FSTFirestoreClient initWithDatabaseInfo:settings:credentialsProvider:userExecutor:workerQueue:]::$_1, std::__1::allocator<-[FSTFirestoreClient initWithDatabaseInfo:settings:credentialsProvider:userExecutor:workerQueue:]::$_1>, void ()>::operator()() (string:1255)
11 Alpaca                         0x1049b7850 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) (atomic:921)
12 Alpaca                         0x1049bef0c firebase::firestore::util::internal::DispatchAsync(NSObject<OS_dispatch_queue>*, std::__1::function<void ()>&&)::$_0::__invoke(void*) (executor_libdispatch.mm:58)
13 libdispatch.dylib              0x1964ca484 _dispatch_client_callout
14 libdispatch.dylib              0x196471bd0 _dispatch_lane_serial_drain$VARIANT$mp
15 libdispatch.dylib              0x196472718 _dispatch_lane_invoke$VARIANT$mp
16 libdispatch.dylib              0x19647aeb8 _dispatch_workloop_worker_thread
17 libsystem_pthread.dylib        0x1966ad0dc _pthread_wqthread
18 libsystem_pthread.dylib        0x1966afcec start_wqthread

screen shot 2019-01-07 at 12 17 11

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions