tests: make issue_848 overflow test portable to 32-bit usize#1881
Open
c-tonneslan wants to merge 1 commit into
Open
tests: make issue_848 overflow test portable to 32-bit usize#1881c-tonneslan wants to merge 1 commit into
c-tonneslan wants to merge 1 commit into
Conversation
The regression test for rust-bakery#848 hardcoded 0x2000000000000000_usize, which is fine on 64-bit but won't fit in a 32-bit usize and fails to compile on i386. Debian ships a downstream patch for this (see rust-bakery#1879). The test just needs a take size large enough to overflow sz.checked_mul(8) inside bits::bytes, i.e. anything bigger than usize::MAX / 8. Switching to usize::MAX / 8 + 1 picks the minimum overflowing value on every platform without a cfg split. Closes rust-bakery#1879 Signed-off-by: Charlie Tonneslan <cst0520@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.
Closes #1879.
The regression test for #848 hardcodes
0x2000000000000000_usize, which is fine on 64-bit but won't fit in a 32-bitusizeand breaks the build on i386 (Debian carries a downstream patch for exactly this).The test only needs the take size to be big enough to overflow
sz.checked_mul(8)insidebits::bytes, i.e. anything strictly greater thanusize::MAX / 8. Switched tousize::MAX / 8 + 1so it picks the minimum overflowing value on every platform without acfg(target_arch = "x86")split.Ran
cargo test --test issues issue_848locally on aarch64-apple-darwin, still passes.