Skip to content

Firestore LevelDbDocumentOverlayCache infinite recursion results in broken app on launch #10469

@sergiocampama

Description

@sergiocampama

Description

It appears that there is a weird issue in firestore which results in an overlay proto message that can't be decoded correctly by nanopb, and ends up in an infinite recursion which ultimately crashes the app. You can see the infinite recursion in the provided crash report.

Copilot-2022-11-08-152134.ips.zip

This first happened on FirebaseFirestore 10.0.0, and nanopb on commit 819d0a2, tag 0.3.9.9 (this was the version of nanopb that Cocoapods installed as a dependency of Firebase). I jumped from Firestore 9.1.0 to 10.0.0. In 9.1.0 I had never seen this issue, and in 10.0.0 I've already had 2 reports on beta testers, which makes me wary of releasing an update with 10.0.0 to the public.

I was able to dump the offending proto message just before the infinite recursion, which I provide below:
nanopbbreakingmessage.bin.zip
. This message is of type google_firestore_v1_Write.

If you notice, that file is pretty big, considering that it has 2 user provided fields for update, and a bunch of repeated __previous_value__, __local_write_time__, __type__ and serv er_timestamp fields. I tried reproducing this error by creating a sample test suite in nanopb to read this message, but on nanopb@master I wasn't able to replicate, and going back to commit nanopb@819d0a2 I wasn't able to run it because of development environment issues.

Reproducing the issue

(Continued from above since there's a limit)

I am at a loss as to how to continue to debug, given the firestore model of sending work to a work queue, making it almost impossible to find where the work is being queued from. I also can't do a binary search to try and find which version introduced this issue (given the overlay mutation is stored somewhere on disk, so even if I rollback to an older version of Firestore it will continue to crash). For some reason reverting back to 9.1.0 avoids the issue, but any version above that presents it (tried 9.6.0 and 9.4.0... 9.3.0 and 9.2.0 have another crashing bug so those versions are invalid for us)

I have the problematic ldb files to share if they are useful, but don't want to share them publicly as it may have some sensitive data.

I have to say, every time I update Firestore I find some issue that appears randomly and forces me to stay in an older version. It's getting incredibly frustrating to maintain a consumer app in these conditions.

(Back to Reproducing the issue)

I have a setup that reproduces the issue somewhat reliably, but I can't share that given it's a private project with private settings, but I'd be happy to jump on a call and show what's happening.

Firebase SDK Version

10.0.0

Xcode Version

14.0

Installation Method

CocoaPods

Firebase Product(s)

Analytics, Authentication, Crashlytics, DynamicLinks, Firestore, Functions, Messaging, Remote Config, Storage

Targeted Platforms

iOS, macCatalyst

Relevant Log Output

See crash report above.

If using Swift Package Manager, the project's Package.resolved

No response

If using CocoaPods, the project's Podfile.lock

Can't add it since "it's too long".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions