-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix Zip unsoundness (again) #141076
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
base: master
Are you sure you want to change the base?
fix Zip unsoundness (again) #141076
Conversation
rustbot has assigned @workingjubilee. Use |
CC @steffahn |
This comment has been minimized.
This comment has been minimized.
1f7a9f5
to
41aca57
Compare
exciting! |
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.
Could you either commit these comments or, if they're wrong (and that seems reasonably likely), correct them? The description of the issue so far is... a bit in-the-weeds. Tests are a valuable opportunity to spend time describing the actual issues we are trying to avoid.
}); | ||
let b = [1, 2, 3, 4].as_slice().iter().copied(); | ||
let c = [5, 6, 7].as_slice().iter().copied(); | ||
let ab = zip(a, b); |
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.
let ab = zip(a, b); | |
// The actual case we are testing: this Zip gets nested in the next, and | |
// `a` forces a premature unwind from Zip's iterator-driving code. | |
let ab = zip(a, b); |
41aca57
to
ec51514
Compare
This comment has been minimized.
This comment has been minimized.
Some history: The Zip TrustedRandomAccess specialization has tried to emulate the side-effects of the naive implementation for a long time, including backwards iteration. 82292¹ tried to fix unsoundness (82291¹) in that side-effect-preservation code, but this introduced some panic-safety unsoundness (86443¹), but the fix 86452¹ didn't fix it for nested Zip iterators (137255¹). Rather than piling yet another fix ontop of this heap of fixes this PR reduces the number of cases in which side-effects will be preserved; the necessary API guarantee change was approved in 83791¹ but we haven't made use of that so far. ¹ see merge commit for linkfied issues.
ec51514
to
61c2c12
Compare
@rustbot ready The issue is complicated, so I don't think those few suggested comments would a good job, so I tried to add some more instead. |
Some history: The Zip TrustedRandomAccess specialization has tried to emulate the side-effects of the naive implementation for a long time, including backwards iteration. #82292 tried to fix unsoundness (#82291) in that side-effect-preservation code, but this introduced some panic-safety unsoundness (#86443), but the fix #86452 didn't fix it for nested Zip iterators (#137255).
Rather than piling yet another fix ontop of this heap of fixes this PR reduces the number of cases in which side-effects will be preserved; the necessary API guarantee change was approved in #83791 but we haven't made use of that so far.
fixes #137255