GeezerVison is showing github.com — Align ancillary send and receive buffers by youknowdot · Pull Request #9642 · RustPython/RustPython
Conversation
youknowdot
commented
Nov 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Encode generic ancillary messages with checked per-message offsets and unaligned header-field stores instead of dereferencing cmsghdr pointers into a Vec<u8>. This also handles platforms such as AIX that do not pad between control messages. Keep the existing public Vec<u8> return API, documenting that its byte allocation does not promise CMSG alignment.
Add an aligned owned buffer for the Python sendmsg path. The buffer is 16-byte aligned for supported platform CMSG layouts, zeroes exposed padding, stays alive through syscall retries and does not add a payload copy beyond the existing snapshots. Bound the combined control size to the CPython 3.15 SOCKLEN_T_LIMIT before constructing it and validate rounded allocation size. Reuse the same initialized, aligned owner for recvmsg_into control storage, including checked size and msg_controllen conversion.
The encoder uses explicit checked offsets rather than CMSG_NXTHDR while building messages. Consequently, it can encode layouts that some previous platform macro boundary checks rejected. The existing infallible allocation policy, Python argument/iovec handling and other socket behavior are unchanged. #9640 independently addresses ancillary parsing and #9638 the AF_ALG-specific send helper.
Validation
- Independent source review covered 16-byte alignment requirements, unaligned AIX headers, initialized bytes, bounds and 32-bit allocation rounding, public API, ownership and retries. No additional per-payload copy was found; performance was not benchmarked.
- Added host-internal tests for aligned and unaligned encoding, zero/odd payloads, multiple headers, zero padding, equivalent legacy/aligned bytes, empty buffers and receive-storage alignment/size checks. These test byte-layout invariants rather than Python API behavior.
rustfmt, git diff --check, and normal repository hooks passed. Source merge-trees were clean against Fix accepting Linux AF_ALG sockets #9637, Safeguard AF_ALG control and send buffers #9638 and Safely parse unaligned ancillary messages #9640.
- No local RustPython build or execution, host-unit-test execution, or cross-target runtime validation. Hosted CI is required; existing
test_socket sendmsg coverage is also relevant where the platform supports it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Important
Draft PR not reviewed
Draft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration:
reviews:
auto_review:
drafts: true
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
youknowdot
changed the title
Align and safely encode ancillary send buffers
Align ancillary send and receive buffers
Nov 3, 2026
codspeed
Bot
commented
Nov 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will not alter performance
✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1
Comparing youknowdot:fix/ancillary-pack-safety-20261103 (b5556ee) with main (3d0f6fc)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR's branch was accidentally reset to main during a force push, which closed it. The reworked change (aligned ControlBuffer + the libc CMSG_* macros for sendmsg, recvmsg/recvmsg_into and sendmsg_afalg) continues in #9818.
— commented by Claude
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|