Skip to content
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

remove InPlaceIterable marker from Peekable due to unsoundness #85340

Merged
merged 3 commits into from
May 20, 2021

Conversation

the8472
Copy link
Member

@the8472 the8472 commented May 15, 2021

The unsoundness is not in Peekable per se, it rather is due to the
interaction between Peekable being able to hold an extra item
and vec::IntoIter's clone implementation shortening the allocation.

An alternative solution would be to change IntoIter's clone implementation
to keep enough spare capacity available.

fixes #85322

@rust-highfive
Copy link
Collaborator

r? @yaahc

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 15, 2021
@SkiFire13
Copy link
Contributor

I think you could also add a regression test, just to make sure this bug is catched if someone will try to implement InPlaceIterable for Peekable again in the future.

@the8472
Copy link
Member Author

the8472 commented May 15, 2021

Right, will do. I might even try to salvage the optimization later so it's good to have a test.

@the8472 the8472 force-pushed the no-inplaceiterable-on-peekable branch from 384b725 to 7d141e1 Compare May 15, 2021 18:42
@jackh726
Copy link
Member

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 15, 2021
@bors
Copy link
Contributor

bors commented May 15, 2021

⌛ Trying commit 7d141e1891b1664b804b0b1a133ffd48fec85a9d with merge e3cdb041f816aa5fee61e1c9e066a4d6f1fd23a0...

@bors
Copy link
Contributor

bors commented May 15, 2021

☀️ Try build successful - checks-actions
Build commit: e3cdb041f816aa5fee61e1c9e066a4d6f1fd23a0 (e3cdb041f816aa5fee61e1c9e066a4d6f1fd23a0)

@rust-timer
Copy link
Collaborator

Queued e3cdb041f816aa5fee61e1c9e066a4d6f1fd23a0 with parent eac3c7c, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (e3cdb041f816aa5fee61e1c9e066a4d6f1fd23a0): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 16, 2021
@the8472
Copy link
Member Author

the8472 commented May 16, 2021

Perf looks neutral.

@rustbot label T-libs-impl

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 16, 2021
@the8472 the8472 force-pushed the no-inplaceiterable-on-peekable branch from e064962 to 6cb81a6 Compare May 16, 2021 19:31
@bors
Copy link
Contributor

bors commented May 18, 2021

☔ The latest upstream changes (presumably #84767) made this pull request unmergeable. Please resolve the merge conflicts.

the8472 and others added 3 commits May 19, 2021 01:41
The unsoundness is not in Peekable per se, it rather is due to the
interaction between Peekable being able to hold an extra item
and vec::IntoIter's clone implementation shortening the allocation.

An alternative solution would be to change IntoIter's clone implementation
to keep enough spare capacity available.
This also checks the contents and not only the capacity in case IntoIter's clone implementation is changed to add capacity at the end. Extra capacity at the beginning would be needed to make InPlaceIterable work.

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
@the8472 the8472 force-pushed the no-inplaceiterable-on-peekable branch from 6cb81a6 to 7cb4e51 Compare May 18, 2021 23:41
@yaahc
Copy link
Member

yaahc commented May 19, 2021

Thank you very much for the fix.

@bors r+

@bors
Copy link
Contributor

bors commented May 19, 2021

📌 Commit 7cb4e51 has been approved by yaahc

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2021
@bors
Copy link
Contributor

bors commented May 19, 2021

⌛ Testing commit 7cb4e51 with merge df70463...

@bors
Copy link
Contributor

bors commented May 20, 2021

☀️ Test successful - checks-actions
Approved by: yaahc
Pushing df70463 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 20, 2021
@bors bors merged commit df70463 into rust-lang:master May 20, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 20, 2021
@pietroalbini pietroalbini added the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 20, 2021
@pietroalbini
Copy link
Member

Nominating to beta backport as requested on Zulip.

@apiraino
Copy link
Contributor

Beta backport approved as per compiler team on Zulip

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label May 20, 2021
@Mark-Simulacrum Mark-Simulacrum removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 22, 2021
@Mark-Simulacrum Mark-Simulacrum modified the milestones: 1.54.0, 1.53.0 May 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2021
…ulacrum

[beta] backports

 * Backport 1.52.1 release notes rust-lang#85404
 * remove InPlaceIterable marker from Peekable due to unsoundness rust-lang#85340
 * rustdoc: Call initSidebarItems in root module of crate rust-lang#85304
 * Update LLVM submodule rust-lang#85236
 * Do not ICE on invalid const param rust-lang#84913
 * Disallows #![feature(no_coverage)] on stable and beta (using standard crate-level gating) rust-lang#84871
 * Ensure TLS destructors run before thread joins in SGX rust-lang#84409
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The implementation of InPlaceIterable for Peekable is unsound