Conversation
496817f replaced bit-at-a-time access with byte loops that assemble the field in a u64. A valid 64-bit field starting one bit into storage spans nine bytes, so get(1, 64) and set(1, 64, value) shift by 64 on the last iteration. The setter also discards the high bit when aligning the value. The existing full-word regression test covered aligned fields and fields ending at bit 64, leaving this crossing case untested. Handle the ninth byte separately, after shifting the first word on reads and before shifting away the high bits on writes. Share the read and write implementations across runtime, raw-pointer, and const-generic accessors instead of maintaining separate usize and u64 algorithms. The const-generic wrappers pass their constants into the inlineable helpers, and the getters remain usable in constants. Store byte-aligned 64-bit fields directly with write_unaligned. Such fields use native byte order and need no read-modify-write. This keeps AArch64 code generation to a single store instead of vectorizing eight byte extractions into shifts, shuffles, and constant-pool loads. Use byte pointers without creating references to the whole storage, so raw access can leave neighboring bytes uninitialized. Check the field's bounds before accessing storage, including in release builds, to preserve the safe accessors' bounds checking and reject invalid writes before modifying any bytes. Replace comparisons between accessors sharing the same algorithm with bit-at-a-time expected values. Cover narrow and full-width fields at every intra-byte offset, preservation of neighboring bits, constant evaluation, indirect storage, and bounds failures. Enable this coverage on both endiannesses while retaining the older little-endian-specific cases behind their existing condition.
Contributor
Author
|
This was written by LLM and reviewed by me. The bug was also spotted by multiple LLMs in aya-rs/aya#1730. |
Collaborator
|
Error: Failed to set assignee to
Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
Contributor
Author
|
r? @emilio |
Contributor
Author
|
Another note: this diff looks much cleaner with |
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.
496817f replaced bit-at-a-time access with byte loops that assemble
the field in a u64. A valid 64-bit field starting one bit into storage
spans nine bytes, so get(1, 64) and set(1, 64, value) shift by 64 on the
last iteration. The setter also discards the high bit when aligning the
value. The existing full-word regression test covered aligned fields and
fields ending at bit 64, leaving this crossing case untested.
Handle the ninth byte separately, after shifting the first word on reads
and before shifting away the high bits on writes. Share the read and
write implementations across runtime, raw-pointer, and const-generic
accessors instead of maintaining separate usize and u64 algorithms. The
const-generic wrappers pass their constants into the inlineable helpers,
and the getters remain usable in constants.
Store byte-aligned 64-bit fields directly with write_unaligned. Such
fields use native byte order and need no read-modify-write. This keeps
AArch64 code generation to a single store instead of vectorizing eight
byte extractions into shifts, shuffles, and constant-pool loads.
Use byte pointers without creating references to the whole storage, so
raw access can leave neighboring bytes uninitialized. Check the field's
bounds before accessing storage, including in release builds, to
preserve the safe accessors' bounds checking and reject invalid writes
before modifying any bytes.
Replace comparisons between accessors sharing the same algorithm with
bit-at-a-time expected values. Cover narrow and full-width fields at
every intra-byte offset, preservation of neighboring bits, constant
evaluation, indirect storage, and bounds failures. Enable this coverage
on both endiannesses while retaining the older little-endian-specific
cases behind their existing condition.