-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
The implementation of InPlaceIterable
for Peekable
is unsound
#85322
Comments
This can be fixed by either removing |
It may also be possible to fix this by specializing |
Hrm, I think it would be possible to do that but it would require some additional helper traits or methods tailored to just this use-case since |
This also effects stable https://godbolt.org/z/4P5sbP6xf @rustbot modify labels: regression-from-stable-to-stable |
Is it a regression though? Marking as @rustbot modify labels -I-prioritize +P-critical |
Technically when #70793 was merged it broke any crate that used code like this (which is not that unexpected like exploting panics and stuff like that). In fact I found this bug due to a project written in only safe rust code that was segfaulting |
This code leads to an out of bounds write, makes the assert fail and triggers miri:
playground
The problem is that after cloning a
Peekable
the inner iterator can no longer be considered advanced, but thePeekable
may still yield the peeked element without advancing it, thus breaking the contract ofInPlaceIterable
.The text was updated successfully, but these errors were encountered: