fix(encode): adjust max pack size for 32-bit targets to prevent overflow#65
Merged
Merged
Conversation
Signed-off-by: linfeng.ouyang <fyoylf@gmail.com>
Contributor
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses 32-bit platform safety by preventing integer overflow in pack size calculations. The changes ensure that pack operations don't cause panics on 32-bit targets where usize is limited to ~4GB.
Key changes:
- Modified cache memory size calculation to use wider arithmetic (u128) preventing overflow when computing 80% of memory limit
- Adjusted test pack size limits to use 2GB on 32-bit targets instead of 6GB to fit within usize bounds
- Added a regression test for 32-bit overflow scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/internal/pack/decode.rs | Fixed cache memory calculation to prevent overflow using u128 intermediate type; added 32-bit specific test case |
| src/internal/pack/encode.rs | Added platform-specific pack size limits in test helper to avoid overflow on 32-bit targets |
yueneiqi
marked this pull request as draft
January 4, 2026 08:41
yueneiqi
marked this pull request as ready for review
January 4, 2026 08:46
31 tasks
Signed-off-by: linfeng.ouyang <fyoylf@gmail.com>
yueneiqi
force-pushed
the
fix/encode-32bit-check
branch
from
January 5, 2026 01:38
58a937d to
2f75678
Compare
genedna
approved these changes
Jan 5, 2026
Merged
genedna
pushed a commit
to genedna/git-internal
that referenced
this pull request
Mar 15, 2026
…low (libra-tools#65) * fix(encode): adjust max pack size for 32-bit targets to prevent overflow Signed-off-by: linfeng.ouyang <fyoylf@gmail.com> * fix(decode): 32-bit overflow in pack cache sizing Signed-off-by: linfeng.ouyang <fyoylf@gmail.com> --------- Signed-off-by: linfeng.ouyang <fyoylf@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When run
buck2 build //... --target-platforms //platforms:i686-unknown-linux-gnuon ci, encounter:This PR fixes that.
Summary
Testing
This PR was primarily authored with Codex using GPT-5.2-Codex and then hand-reviewed by me. I AM responsible for every change made in this PR. I aimed to keep it aligned with our goals, though I may have missed minor issues. Please flag anything that feels off, I'll fix it quickly.