Uh oh!
There was an error while loading. Please reload this page.
Fix unsoundness for VecDeque - #53571
Conversation
RalfJung
commented
Aug 21, 2018
I fully agree with the For the revert, maybe we want to keep the tests and benches? |
varkor
commented
Aug 21, 2018
Shouldn't there be a test to make sure the unsoundness couldn't be accidentally reintroduced in the future? |
RalfJung
commented
Aug 21, 2018
We can't really test for UB... ... except miri can. I guess someone could add a test to the miri test suite. Ideally doing more than just a debug print; essentially running much of the rustc test suite covering |
322261c to
3bf2cd4CompareMaloJaffre
commented
Aug 22, 2018
@RalfJung I've now restored the tests and the benches. |
RalfJung
commented
Aug 22, 2018
What kind of test do you plan to add? |
MaloJaffre
commented
Aug 22, 2018
…onSapin" This partially reverts commit d5b6b95, reversing changes made to 6b1ff19. Fixesrust-lang#53529. Cc: rust-lang#53564.
RalfJung
commented
Aug 22, 2018
Hm, I think this would make more sense as a unit test in |
3a1d997 to
41c43f5CompareMaloJaffre
commented
Aug 22, 2018
@RalfJung Done! |
RalfJung
commented
Aug 22, 2018
Awesome! r=me once traivs is happy. @bors delegate+ |
bors
commented
Aug 22, 2018
✌️ @MaloJaffre can now approve this pull request |
rust-highfive
commented
Aug 22, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
RalfJung
commented
Aug 22, 2018
Oh while you are fixing this anyway, maybe you could add some assertions checking that we are getting back the values we expect (in |
41c43f5 to
30c3fb3CompareMaloJaffre
commented
Aug 22, 2018
Sure! |
30c3fb3 to
3133025Compare3133025 to
f8d5ed4CompareMaloJaffre
commented
Aug 22, 2018
@bors r=RalfJung |
bors
commented
Aug 22, 2018
📌 Commit f8d5ed4 has been approved by |
bors
commented
Aug 23, 2018
bors
commented
Aug 23, 2018
☀️ Test successful - status-appveyor, status-travis |
Reoptimize VecDeque::append ~Unfortunately, I don't know if these changes fix the unsoundness mentioned in #53529, so it is stil a WIP. This is also completely untested. The VecDeque code contains other unsound code: one example : [reading unitialized memory](https://play.rust-lang.org/?gist=6ff47551769af61fd8adc45c44010887&version=nightly&mode=release&edition=2015) (detected by MIRI), so I think this code will need a bigger refactor to make it clearer and safer.~ Note: this is based on #53571. r? @SimonSapin Cc: #53529#52553@yorickpeterse@jonas-schievink@Pazzaz@shepmaster.
Shnatsel
commented
Feb 17, 2019
Regarding a regression test for this: Memory Sanitizer would also have discovered this issue, and it introduces tolerable (~3x) slowdown, which is much less extreme than MIRI. |
Optimize VecDeque::append Optimize `VecDeque::append` to do unsafe copy rather than iterating through each element. On my `Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz`, the benchmark shows 37% improvements: ``` Master: custom-bench vec_deque_append 583164 ns/iter custom-bench vec_deque_append 550040 ns/iter Patched: custom-bench vec_deque_append 349204 ns/iter custom-bench vec_deque_append 368164 ns/iter ``` Additional notes on the context: this is the third attempt to implement a non-trivial version of `VecDeque::append`, the last two are reverted due to unsoundness or regression, see: - rust-lang#52553, reverted in rust-lang#53571 - rust-lang#53564, reverted in rust-lang#54851 Both cases are covered by existing tests. Signed-off-by: tabokie <xy.tao@outlook.com>
See individual commit for more details.
r? @RalfJung.
Fixes#53566, fixes#53529