Description
https://github.com/couchbase/couchbase-lite-C/issues/209
C4Query::liveQuerier breaks the rule about calling external code while holding an internal lock. As a result there is a situation where via convoluted circular mechanisms the code can end up back in C4Query and attempt to seize the lock again, resulting in a deadlock:
- C4Query::liveQuerierUpdated seizes lock
- C4QueryObserverImpl::notify
- ListenerToken observe callback
- ListenerToken::queryChanged
- CBLDatabase::notify
- Above function retains the listener token passed into it
- All other areas in the meantime release the listener token (ref count = 1)
- At the end of notify listener token is released to 0
- ~ListenerToken<CBLQueryChangeListener>()
- ListenerToken<CBLQueryChangeListener>::setEnabled
- C4QueryObserverImpl::setEnabled
- C4Query::enableObserver deadlock
Recommendation: Call the observe methods without holding the lock, if possible
Attachments
Issue Links
- relates to
-
CBL-2391 Lithium backports
- Closed