fix(crashlytics): serialize INT64_MIN without overflow - #16773
dajiaohuang wants to merge 3 commits into
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
Thanks for the contribution! A few housekeeping items:
|
paulb777
left a comment
There was a problem hiding this comment.
Thanks. Negating INT64_MIN is undefined behavior, so this is a fair cleanup. In practice, though, the written output was already -9223372036854775808 (only UBSan would flag it). Following up on my earlier comment: please reword the CHANGELOG entry to match (e.g. "Avoid signed integer overflow when serializing INT64_MIN"), or drop it.
CI shows testMinInt64 failing; the cause is inline. The other catalyst failure is the FIRCLSContextManagerTests crash fixed in #16776. Since this and #16772 both touch FIRCLSFile.m, feel free to fold this into #16772.
|
The JSON regression already has the missing FIRCLSFileWriteHashStart call from the prior follow-up. Both signed writer paths now use the suggested unsigned subtraction, and the changelog is under Unreleased with #16773 and describes avoiding signed overflow rather than changing the already-correct printed value. The changed source/test files pass clang-format 23.1.2 and git diff --check. For the requested sanitizer distinction, I compiled the actual pre-PR and updated signed writer function bodies on Linux with UBSan and no recovery. The pre-PR INT64_MIN path reports signed overflow; both updated writer functions pass INT64_MIN, INT64_MAX, -1, 0 and 1 (10 cases). The storage and unsigned-output helpers were stubbed for this focused test; it is not a full Crashlytics/XCTest execution. Native Apple XCTest remains for CI. I kept this existing PR separate from #16772 so the overflow change stays independently reviewable. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request fixes a signed integer overflow issue when serializing INT64_MIN by casting the value to uint64_t before computing its magnitude, and adds corresponding unit tests. Feedback suggests refactoring the magnitude assignment in FIRCLSFileWriteInt64 and FIRCLSFileFDWriteInt64 to use an if-else block with idiomatic unary negation instead of redundant initialization and subtraction from zero. Additionally, it is recommended to use INT64_MIN directly in the unit test assertion for better readability.
Summary
Validation