Repository navigation
Cherry pick #133530 to 26.3: Fix handling of groups and named unions in CapnProto format - #133754
Merged
Merged
Conversation
A Cap'n Proto group (`g :group { ... }`, and a named union
`u :union { ... }` as well) is stored inline in the struct that contains
it. The serializer treated such a field as a pointer field of the parent
struct, so the data was written to and read from the wrong place, and
for a parent struct without pointers the access was out of bounds of the
struct.
Access the group through the storage of its parent struct, both when
writing and when reading, and do not read the slot offset from the proto
of a field that is not a slot.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…n `CapnProto` Address review: `CapnProtoNullableSerializer` took the slot offset of the value from the first member of the union, assuming both members have the same offset. This holds for a standalone struct with a union, but not for a named union declared inline in a struct: the `Void` member always has offset 0, while the value can be in any slot of the enclosing struct. For a union with the `Void` member first, the value was written over (and read from) the slot 0 of the parent, corrupting a sibling field. Now the offset is taken from the non-`Void` member. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…in `CapnProto` Address review: for a column with a flattened name such as `g.h` and the type `Tuple`, `CapnProtoStructureSerializer` for `g` is an adapter with a single field serializer (for `h`), but `writeRowImpl` and `readRowImpl` decided what to do by the type of the column: for `ColumnTuple` they iterated over the tuple elements and accessed `fields_serializers` and `fields_offsets` out of bounds. Now the serializer remembers whether it maps a struct to a `Tuple`, and otherwise passes the whole column to its single field. This affected both groups and standalone structs. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Extend `05843_capnproto_group_fields` with: - named unions with the `Void` member first, declared after other data and pointer fields, so the value is not in the slot 0; the written data is also read through a struct with the same layout and plain fields to check that the sibling fields and the discriminants are in the right places; - a `Tuple` column under a flattened name (`g.h`), for a group and for a standalone struct. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Columns with flattened names (like `l.x` and `l.y`) are written to the same list and share its cached builder, which is created with the size of the first array. An array of another size was then written through that builder: a longer one accessed its element builders out of bounds, a shorter one silently left the remaining elements unset. Throw `SIZES_OF_ARRAYS_DONT_MATCH` in `CapnProtoArraySerializer` instead. It applies to lists inside groups and inside standalone structs. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Fix handling of groups and named unions in CapnProto format
…ypick/26.3/133530 Resolve the conflict in `CapnProtoSerializer.cpp`: keep the 26.3 member declarations and add `is_tuple`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.
Original pull-request #133530
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job