Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-2942

LiveQuery could crash when removing the listener

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.0.2
    • 3.0
    • C, LiteCore
    • Security Level: Public
    • None
    • 3

    Description

      Reported in https://github.com/couchbase/couchbase-lite-C/issues/288.

      Analysis from the report:

      I think that the root cause is that it is unsafe to call C4Query::enableObserver multiple times with the last observer.
      The ListenerToken of a query disables itself in its destructor, which leads to a call of C4Query::enableObserver, and when the C4QueryObserver that is owned by the ListenerToken is implicitly destroyed C4Query::enableObserver is called again.

      The problem with C4Query::enableObserver is that it allows multiple consecutive calls to enter this code section which calls LiveQuerier::stop, an actor method which executes asynchronously.
      When the LiverQuerier has stopped, C4Query::liveQuerierStopped is called, which releases _bgQuerier.
      In this case, this happens while the second call to C4Query::enableObserver is still executing.

      Attachments

        Issue Links

          Activity

            People

              pasin Pasin Suriyentrakorn
              pasin Pasin Suriyentrakorn
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty