Skip to content

Assert triggered in DocumentReference::AddSnapshotListener #85

Closed
@canatella

Description

@canatella

Please fill in the following fields:

Pre-built SDK from the website or open-source from this repo: prebuilt
Firebase C++ SDK version: tested on 6.15.0 and 6.15.1
Firebase plugins in use (Auth, Database, etc.): Auth, Firestore
Additional SDKs you are using (Facebook, AdMob, etc.):
Platform you are using the C++ SDK on (Mac, Windows, or Linux): Mac
Platform you are targeting (iOS, Android, and/or desktop): Android

Please describe the issue here:

When calling DocumentReference::AddSnapshotListener and asking for metadata changes while using a lambda as callback argument, the assertion at lambda_event_listener.h:23 is triggered. What seems strange to me is that the one at firestore/src/common/document_reference.cc:164 is not triggered. Also the same code is working on iOS and on Mac. Using a static function and globals to store the state is also working. Here is the code:

void
backend_firebase::create_chunk_data_done(const session_info &session,
                                         const std::shared_ptr<session_handler> &handler,
                                         std::size_t transferred,
                                         const firebase::Future<void> &future)
{
    if (future.error() != Error::kErrorOk) {
        ...
    }

    // Prepare an updated session with the new transferred bytes count.
    auto updated_session = session;
    updated_session.raw_bytes_transferred += transferred;

    // Setup a listener on the chunk document to know when the data has been
    // uploaded to the backend.
    auto chunk_ref = chunks(session.id).Document(fmt::format("{}", session.raw_bytes_transferred));
    chunk_listener_ = chunk_ref.AddSnapshotListener(
        firebase::firestore::MetadataChanges::kInclude,
        [this, updated_session, handler](const auto &snapshot, auto error) {
            create_chunk_data_uploaded(updated_session, handler, snapshot, error);
        });
}

and a stack trace:

07-14 16:34:41.988 14222 14222 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-14 16:34:41.989 14222 14222 F DEBUG   : Build fingerprint: 'OnePlus/OnePlus6/OnePlus6:10/QKQ1.190716.003/2005052051:user/release-keys'
07-14 16:34:41.989 14222 14222 F DEBUG   : Revision: '0'
07-14 16:34:41.989 14222 14222 F DEBUG   : ABI: 'arm64'
07-14 16:34:41.990 14222 14222 F DEBUG   : Timestamp: 2020-07-14 16:34:41+0200
07-14 16:34:41.990 14222 14222 F DEBUG   : pid: 13603, tid: 13603, name: mlife.flib.test  >>> com.bloomlife.flib.test <<<
07-14 16:34:41.990 14222 14222 F DEBUG   : uid: 10892
07-14 16:34:41.990 14222 14222 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
07-14 16:34:41.990 14222 14222 F DEBUG   : Abort message: 'callback'
07-14 16:34:41.990 14222 14222 F DEBUG   :     x0  0000000000000000  x1  0000000000003523  x2  0000000000000006  x3  0000007ffc073f60
07-14 16:34:41.990 14222 14222 F DEBUG   :     x4  fefeff7097133eff  x5  fefeff7097133eff  x6  fefeff7097133eff  x7  7f7f7f7fff7f7f7f
07-14 16:34:41.990 14222 14222 F DEBUG   :     x8  00000000000000f0  x9  d4053e0f972fcdb0  x10 0000000000000001  x11 0000000000000000
07-14 16:34:41.990 14222 14222 F DEBUG   :     x12 fffffff0fffffbdf  x13 ffffffffffffffff  x14 0000000000000004  x15 ffffffffffffffff
07-14 16:34:41.990 14222 14222 F DEBUG   :     x16 000000719473b8c0  x17 0000007194717900  x18 00000071984ac000  x19 0000000000003523
07-14 16:34:41.990 14222 14222 F DEBUG   :     x20 0000000000003523  x21 00000000ffffffff  x22 000000709fb5a779  x23 0000007198144020
07-14 16:34:41.990 14222 14222 F DEBUG   :     x24 000000709fb5a770  x25 0000007ffc074200  x26 0000007ffc074b40  x27 0000007198144020
07-14 16:34:41.990 14222 14222 F DEBUG   :     x28 0000000000000001  x29 0000007ffc074000
07-14 16:34:41.990 14222 14222 F DEBUG   :     sp  0000007ffc073f40  lr  00000071946c90c4  pc  00000071946c90f0
07-14 16:34:42.003 14222 14222 F DEBUG   : 
07-14 16:34:42.003 14222 14222 F DEBUG   : backtrace:
07-14 16:34:42.003 14222 14222 F DEBUG   :     NOTE: Function names and BuildId information is missing for some frames due
07-14 16:34:42.003 14222 14222 F DEBUG   :     NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
07-14 16:34:42.003 14222 14222 F DEBUG   :     NOTE: found under the lib/ directory are readable.
07-14 16:34:42.003 14222 14222 F DEBUG   :        (abort+160) (BuildId: a6a4a6a4e20240bbe3173fe560b161af)
07-14 16:34:42.003 14222 14222 F DEBUG   :       /tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/log.cc:85 (firebase::DefaultLogCallback(firebase::LogLevel, char const*, void*)+44) (BuildId: 7ed82db96020ef7bb1ae1133cc900c3bc5d23910)
07-14 16:34:42.003 14222 14222 F DEBUG   :       /tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/log.cc:149 (firebase::LogMessageWithCallbackV(firebase::LogLevel, char const*, std::__va_list)+220) (BuildId: 7ed82db96020ef7bb1ae1133cc900c3bc5d23910)
07-14 16:34:42.003 14222 14222 F DEBUG   :       /tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/log.cc:200 (firebase::LogAssert(char const*, ...)+128) (BuildId: 7ed82db96020ef7bb1ae1133cc900c3bc5d23910)
07-14 16:34:42.003 14222 14222 F DEBUG   :       /tmpfs/src/gfile/kokoro_firestoreandroid/firebase/firestore/client/cpp/src/android/lambda_event_listener.h:23 (firebase::firestore::DocumentReferenceInternal::AddSnapshotListener(firebase::firestore::MetadataChanges, std::__ndk1::function<void (firebase::firestore::DocumentSnapshot const&, firebase::firestore::Error)>)+256) (BuildId: 7ed82db96020ef7bb1ae1133cc900c3bc5d23910)
07-14 16:34:42.003 14222 14222 F DEBUG   :       /tmpfs/src/gfile/kokoro_firestoreandroid/firebase/firestore/client/cpp/src/common/document_reference.cc:166 (firebase::firestore::DocumentReference::AddSnapshotListener(firebase::firestore::MetadataChanges, std::__ndk1::function<void (firebase::firestore::DocumentSnapshot const&, firebase::firestore::Error)>)+192) (BuildId: 7ed82db96020ef7bb1ae1133cc900c3bc5d23910)
07-14 16:34:42.003 14222 14222 F DEBUG   :       .../backend_firebase.cpp:1128 (backend_firebase::create_chunk_data_done(session_info const&, std::__ndk1::shared_ptr<bloom::flib::database::session_handler> const&, unsigned long, firebase::Future<void> const&)+660) 

Please answer the following, if applicable:

Have you been able to reproduce this issue with just the Firebase C++ quickstarts ?

No

What's the issue repro rate? (eg 100%, 1/5 etc) 100%

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions