Repository navigation
pyclass: reject unsupported alignment - #6571
Open
JMak-Security wants to merge 6 commits into
Open
JMak-Security wants to merge 6 commits into
JMak-Security wants to merge 6 commits into
Conversation
Python's object allocator does not guarantee alignment beyond 16 bytes on 64-bit platforms or 8 bytes on 32-bit platforms. Reject unsupported layouts at compile time and document boxing over-aligned data. Co-authored-by: Copilot <[email protected]>
Reflow the alignment guidance to satisfy rumdl and add the required fixed changelog fragment. Co-authored-by: Copilot <[email protected]>
Use the maximum alignment guaranteed by Python's allocator in the disjoint-base test fixture, and lower its base field alignment so the padding assertion remains meaningful. Co-authored-by: Copilot <[email protected]>
Exercise the allocator-alignment guard's rejecting branch at runtime so the new safety check is covered by the test suite. Co-authored-by: Copilot <[email protected]>
Exercise the allocator-alignment check's passing branch in the unit test so the new guard is fully covered. Co-authored-by: Copilot <[email protected]>
Avoid relying on the runner's system Python version, which changed with ubuntu-latest and broke the FFI macro checks. Co-authored-by: Copilot <[email protected]>
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.
Summary
#[pyclass]layouts whose alignment exceeds the guarantee of Python's object allocator (16 bytes on 64-bit, 8 bytes on 32-bit) for both static and variable layouts.Boxfor over-aligned data.This prevents undefined behavior when Rust references an object Python allocated at an insufficiently aligned address. Addresses #5714 and duplicate report #6526.
Validation
cargo fmt --all -- --check— passedgit diff --check— passedrustcconst-evaluation check — 16-byte alignment accepted and 32-byte alignment rejected on 64-bitlink.exe) and Windows SDK libraries.