Skip to content

[FirebaseCoreInternal] Guard against invalid indexing into RingBuffer type #10032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 22, 2022

Conversation

ncooke3
Copy link
Member

@ncooke3 ncooke3 commented Jul 20, 2022

Context

An issue was reported where the issue's crash report suggests an index out of bounds exception in the RingBuffer type. This type is used by FirebaseCoreInternal's heartbeat component. RingBuffer internally manages an insertion index that is incremented/decremented to always be within the inner array's bounds. In the reported issue, that assumption was being broken for some reason.

To prevent the crash, the crashing RingBuffer API is converted to a throwing method that throws an error if the insertion index is out of bounds. This is gracefully handled in the calling context to reset the ring buffer in an effort to return things to a normal state.

Fixes #10025

@google-oss-bot
Copy link

google-oss-bot commented Jul 20, 2022

Coverage Report 1

Affected Products

  • FirebaseFirestore-iOS-FirebaseFirestore.framework

    Overall coverage changed from 88.40% (7e3548b) to 88.42% (b611821) by +0.02%.

    FilenameBase (7e3548b)Merge (b611821)Diff
    leveldb_key.cc98.14%98.63%+0.49%

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/a47oqzhoa8.html

@ncooke3 ncooke3 changed the title [FirebaseCoreInternal] Refactor indexing logic in core internal's RingBuffer code [FirebaseCoreInternal] Guard against invalid indexing into RingBuffer type Jul 21, 2022
@ncooke3 ncooke3 merged commit aaeb5f4 into master Jul 22, 2022
@ncooke3 ncooke3 deleted the nc/heartbeat-pushing branch July 22, 2022 18:29
@firebase firebase locked and limited conversation to collaborators Aug 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermittent FirebaseCoreInternal: specialized RingBuffer.push(_:) + 380 crash
4 participants