firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.56k stars 1.45k forks source link

FirebaseFirestore shared_ptr.h - Line 52 firebase::firestore::model::MutableDocument::MutableDocument() + 52 #9709

Closed sspogra closed 2 years ago

sspogra commented 2 years ago

Crashed: com.google.firebase.firestore 0 libsystem_kernel.dylib 0x277b0 pthread_kill + 8 1 libsystem_pthread.dylib 0xa9c0 pthread_kill + 212 2 libsystem_c.dylib 0x73a44 abort + 100 3 libsystem_malloc.dylib 0x1d0a8 _malloc_put + 554 4 libsystem_malloc.dylib 0x1d31c malloc_zone_error + 100 5 libsystem_malloc.dylib 0x2288 nanov2_allocate_from_block$VARIANT$mp + 544 6 libsystem_malloc.dylib 0x14bc nanov2_allocate$VARIANT$mp + 124 7 libsystem_malloc.dylib 0x13f0 nanov2_malloc$VARIANT$mp + 60 8 libsystem_malloc.dylib 0x12ad8 _malloc_zone_malloc + 144 9 libc++abi.dylib 0x14660 operator new(unsigned long) + 28 10 FirebaseFirestore 0xe7b0 firebase::firestore::model::MutableDocument::MutableDocument() + 52 (shared_ptr.h:52) 11 FirebaseFirestore 0x13de7c std::__1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange>::pair<true, false>() + 64 (view_snapshot.h:64) 12 FirebaseFirestore 0x13fa1c firebase::firestore::immutable::impl::FixedArray<std::1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> >::FixedArray<std::1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> const*>(std::1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> const, std::__1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> const) + 129 (array:129) 13 FirebaseFirestore 0x13f50c std::1::shared_ptr<firebase::firestore::immutable::impl::FixedArray<std::1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> > > std::1::make_shared<firebase::firestore::immutable::impl::FixedArray<std::1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> >, std::1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> const*, std::1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> const&, void>(std::__1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> const&&, std::1::pair<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange> const*&) + 635 (shared_ptr.h:635) 14 FirebaseFirestore 0x13d988 firebase::firestore::immutable::impl::ArraySortedMap<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange, firebase::firestore::util::Comparator >::insert(firebase::firestore::model::DocumentKey const&, firebase::firestore::core::DocumentViewChange const&) const + 589 (shared_ptr.h:589) 15 FirebaseFirestore 0x13b74c firebase::firestore::immutable::SortedMap<firebase::firestore::model::DocumentKey, firebase::firestore::core::DocumentViewChange, firebase::firestore::util::Comparator >::insert(firebase::firestore::model::DocumentKey const&, firebase::firestore::core::DocumentViewChange const&) const + 371 (sorted_map.h:371) 16 FirebaseFirestore 0x13ad54 firebase::firestore::core::DocumentViewChangeSet::AddChange(firebase::firestore::core::DocumentViewChange&&) + 65 (view_snapshot.cc:65) 17 FirebaseFirestore 0x1357a0 firebase::firestore::core::View::ComputeDocumentChanges(firebase::firestore::immutable::SortedMap<firebase::firestore::model::DocumentKey, firebase::firestore::model::Document, firebase::firestore::util::Comparator > const&, absl::lts_2020_02_25::optional const&) const + 958 (shared_ptr.h:958) 18 FirebaseFirestore 0x11fa28 firebase::firestore::core::SyncEngine::EmitNewSnapshotsAndNotifyLocalStore(firebase::firestore::immutable::SortedMap<firebase::firestore::model::DocumentKey, firebase::firestore::model::Document, firebase::firestore::util::Comparator > const&, absl::lts_2020_02_25::optional const&) + 475 (sync_engine.cc:475) 19 FirebaseFirestore 0x11f52c firebase::firestore::core::SyncEngine::WriteMutations(std::1::vector<firebase::firestore::model::Mutation, std::1::allocator >&&, std::1::function<void (firebase::firestore::util::Status)>) + 212 (sync_engine.cc:212) 20 FirebaseFirestore 0x6a008 std::1::function::func<firebase::firestore::core::FirestoreClient::WriteMutations(std::1::vector<firebase::firestore::model::Mutation, std::1::allocator >&&, std::1::function<void (firebase::firestore::util::Status)>)::$_15, std::1::allocator<firebase::firestore::core::FirestoreClient::WriteMutations(std::1::vector<firebase::firestore::model::Mutation, std::1::allocator >&&, std::1::function<void (firebase::firestore::util::Status)>)::$_15>, void ()>::operator()() + 463 (function.h:463) 21 FirebaseFirestore 0x7034 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) + 997 (atomic:997) 22 FirebaseFirestore 0x12a314 firebase::firestore::util::Task::ExecuteAndRelease() + 491 (function.h:491) 23 libdispatch.dylib 0x61298 _dispatch_client_callout + 16 24 libdispatch.dylib 0x9a40 _dispatch_lane_serial_drain$VARIANT$mp + 612 25 libdispatch.dylib 0xa518 _dispatch_lane_invoke$VARIANT$mp + 420 26 libdispatch.dylib 0x13fac _dispatch_workloop_worker_thread + 712 27 libsystem_pthread.dylib 0xb5bc _pthread_wqthread + 272 28 libsystem_pthread.dylib 0xe86c start_wqthread + 8

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

App was crashed on updating data on firestore document while the app is in background state.

Here is the log:- Path = users.16823, Data = { "current_location" = "<FIRGeoPoint: (31.132658, -89.431470)>"; "location_updated_at" = ""; }

Relevant Code:

let data = [
            "current_location" :  GeoPoint(latitude:31.132658, longitude: -89.431470),
            "location_updated_at" : Timestamp(date: Date())
        ]
Firestore.firestore().collection("users")
            .document(16823)
            .setData(data, merge: true)
google-oss-bot commented 2 years ago

I found a few problems with this issue:

dconeybe commented 2 years ago

It looks like the crash is happening while allocating heap memory for the shared_ptr in MutableDocument:

https://github.com/firebase/firebase-ios-sdk/blob/aefb2a469b012f06d2761efbb79a25c21b0b82ad/Firestore/core/src/model/mutable_document.h#L239

The presence of malloc_zone_error in the stack trace suggests heap corruption (according to an internet search). I don't see anything obvious in the stack trace that points to a root cause.

Are you able to reproduce while running your app with address sanitizer or malloc guard?

I'm not sure how to proceed without more information though. Is there any more context you can provide? A reproducible app would be the best, but I understand that may not be possible.

google-oss-bot commented 2 years ago

Hey @sspogra. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@sspogra if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.