-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Fix vec iter zst alignment #149272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix vec iter zst alignment #149272
Conversation
|
This PR modifies |
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the file name needs to be changed.
https://rustc-dev-guide.rust-lang.org/tests/best-practices.html#test-naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using the issues directory, please refer to this and choose a more appropriate location.
tests/ui/issues/issue-148682.rs
Outdated
| @@ -0,0 +1,9 @@ | |||
| // check-pass | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // check-pass | |
| //@ check-pass |
This comment has been minimized.
This comment has been minimized.
|
r? libs |
|
@reddevilmidzy Thanks! Updated as requested. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and please squash
| // @ check-pass | ||
| //test Intolter::nth_back does not cause UB for ZSTs with high alignment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove leading spaces from commands, and add a space before comments.
| // @ check-pass | |
| //test Intolter::nth_back does not cause UB for ZSTs with high alignment | |
| //@ check-pass | |
| // test Intolter::nth_back does not cause UB for ZSTs with high alignment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!It seems that all the CI tests are passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using the issues directory, please refer to this and choose a more appropriate location.
|
Could you please add |
ceb3c6f to
069f53f
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
069f53f to
d94bb76
Compare
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
|
Also, please run |
e608b3a to
ef2ceec
Compare
This comment has been minimized.
This comment has been minimized.
ef2ceec to
89b4b30
Compare
|
Builds are green and I've addressed all feedback (moved test to library/alloc/tests/vec.rs). @rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with extra tests added
|
Reminder, once the PR becomes ready for a review, use |
library/alloctests/tests/vec.rs
Outdated
| // Regression test for Undefined Behavior (UB) caused by IntoIter::nth_back (#148682) | ||
| // when dealing with high-aligned Zero-Sized Types (ZSTs). | ||
| #[test] | ||
| fn zst_vec_iter_nth_back_regression() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests for other collections that I suspect may well have the same bug? At the very least VecDeque, BTreeMap, HashMap, and BinaryHeap all seem likely to be potentially at risk.
This comment has been minimized.
This comment has been minimized.
This commit consolidates all changes, including the core logic fix for IntoIter::nth_back and the addition of the Miri regression test in `library/alloctests/tests/vec.rs`, to prevent Undefined Behavior (UB) when dealing with highly-aligned Zero-Sized Types.
a246d47 to
34392a9
Compare
|
Thanks for the review! @Mark-Simulacrum I've addressed your comments and pushed the changes. Let me know if there's anything else needed. |
|
@bors r+ |
…-148682, r=Mark-Simulacrum Fix vec iter zst alignment Closes rust-lang#148682
Rollup of 8 pull requests Successful merges: - #148755 (Constify `DropGuard::dismiss` and trait impls) - #148825 (Add SystemTime::{MIN, MAX}) - #149272 (Fix vec iter zst alignment) - #149417 (tidy: Detect outdated workspaces in workspace list) - #149437 (Fix trailing newline in JUnit formatter) - #149773 (fix va_list test by adding a llvmir signext check) - #149894 (Update to mdbook 0.5) - #149955 (Fix typo in armv7a-vex-v5 documentation) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - #148755 (Constify `DropGuard::dismiss` and trait impls) - #148825 (Add SystemTime::{MIN, MAX}) - #149272 (Fix vec iter zst alignment) - #149417 (tidy: Detect outdated workspaces in workspace list) - #149773 (fix va_list test by adding a llvmir signext check) - #149894 (Update to mdbook 0.5) - #149955 (Fix typo in armv7a-vex-v5 documentation) - #149972 (Enable to ping LoongArch group via triagebot) r? `@ghost` `@rustbot` modify labels: rollup
Closes #148682