Repository navigation
Conversation
melver
requested review from
kroening,
martin-cs,
peterschrammel and
tautschnig
as code owners
October 28, 2026 09:28
Consider a store that straddles two members of a packed struct:
#pragma pack(push, 1)
struct S
{
uint32_t a; // bytes 0..3
uint64_t c; // bytes 4..11
uint32_t d; // bytes 12..15
};
#pragma pack(pop)
struct S s;
*(uint64_t *)((char *)&s + 8) = v; // bytes 8..15
The simplifier splits the resulting byte_update of s into per-member
updates:
s.c = byte_update(s.c, 4, v); // v's bytes 0..3 -> c's bytes 4..7
s.d = byte_extract(v, 4); // v's bytes 4..7 -> d
The simplifier passes all 8 bytes of v as the update value, but only 4
of them fit in c from offset 4 onwards; v's remaining 4 bytes extend
past the end of c. Such updates are well-formed: lower_byte_update
applies the overlapping part, as does the variable-offset encoding in
convert_byte_update for non-negative offsets. The constant-offset
encoding, however, treated any update that did not fit entirely within
the updated object as out of bounds and discarded all of it. Bytes 8..11
of s thus kept their old value, while bytes 12..15 were updated, on both
little- and big-endian configurations. The SMT2 back-end, which lowers
byte operators, was not affected.
Make the constant-offset encoding update only the bits that lie within
the updated object. This also handles negative constant offsets.
melver
force-pushed
the
fix-byte-update-partial-overlap
branch
from
November 8, 2026 13:36
87e05fb to
d54407b
Compare
This branch has not been deployed
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.
Consider a store that straddles two members of a packed struct:
The simplifier splits the resulting byte_update of s into per-member updates:
The simplifier passes all 8 bytes of v as the update value, but only 4 of them fit in c from offset 4 onwards; v's remaining 4 bytes extend past the end of c. Such updates are well-formed: lower_byte_update applies the overlapping part, as does the variable-offset encoding in convert_byte_update for non-negative offsets. The constant-offset encoding, however, treated any update that did not fit entirely within the updated object as out of bounds and discarded all of it. Bytes 8..11 of s thus kept their old value, while bytes 12..15 were updated, on both little- and big-endian configurations. The SMT2 back-end, which lowers byte operators, was not affected.
Make the constant-offset encoding update only the bits that lie within the updated object. This also handles negative constant offsets.
Assisted-by: Antigravity