Repository navigation
Test for drains that shift the tail, when inline - #271
Merged
Merged
Conversation
saethlin
force-pushed
the
drain-aliasing-test
branch
from
December 19, 2021 23:43
5a87ff3 to
f79171c
Compare
jdm
approved these changes
Dec 20, 2021
Member
|
@bors-servo r+ |
Contributor
|
📌 Commit f79171c has been approved by |
Contributor
bors-servo
added a commit
that referenced
this pull request
Dec 20, 2021
Test for drains that shift the tail, when inline Previously, the test suite only had one trip through the tail-shifting code in Drain::drop, and that is in the heap state. In the current implementation, a tail-shifting drain while in the inline state produces potentially dangerous aliasing which is currently accepted by default Miri and rejected with -Ztrack-raw-pointers. Adding this test case ensures that if this ever becomes an actual problem it will be easy to find.
Contributor
|
💔 Test failed - checks-github |
Contributor
Author
|
@bors retry |
Previously, the test suite only had one trip through the tail-shifting code in Drain::drop, and that is in the heap state. In the current implementation, a tail-shifting drain while in the inline state produces potentially dangerous aliasing which is currently accepted by default Miri and rejected with -Ztrack-raw-pointers. Adding this test case ensures that if this ever becomes an actual problem it will be easy to find.
saethlin
force-pushed
the
drain-aliasing-test
branch
from
January 3, 2022 04:16
f79171c to
0fced9d
Compare
Contributor
Author
|
The bors failure above was only because the nightly that day didn't have a miri. I was trying to prompt for a retry, but I guess I can't :( |
Member
|
@bors-servo retry |
Member
|
@bors-servo r+ |
Contributor
|
📌 Commit 0fced9d has been approved by |
Contributor
Contributor
|
☀️ Test successful - checks-github |
bors-servo
added a commit
that referenced
this pull request
Feb 1, 2022
Fix all problems encounted with Miri -Ztag-raw-pointers I poked at this crate with `-Zmiri-tag-raw-pointers` before, and I was unable to fix what I found (I just added a test case that ruled out one of my wrong ideas #271). I tried again just now and I guess I just understand better this time. This PR fixes 3 separate pointer invalidation problems, which are detected by running `MIRIFLAGS=-Zmiri-tag-raw-pointers cargo miri test`. Depending on how you squint, 2 or 3 of these are rust-lang/unsafe-code-guidelines#133. The last one is _probably_ still present even with late invalidation, because `set_len` does a write through a `&mut`. It's unclear to me if any of these things that Miri complains about are potentially a miscompilation in rustc due to the use of LLVM `noalias`. But perhaps given how subtle this codebase is overall, it would be best to run the tools on their pickiest settings, even if there are a few things more like a false positive than a real problem.
bors-servo
added a commit
that referenced
this pull request
Feb 7, 2022
Fix all problems encounted with Miri -Ztag-raw-pointers I poked at this crate with `-Zmiri-tag-raw-pointers` before, and I was unable to fix what I found (I just added a test case that ruled out one of my wrong ideas #271). I tried again just now and I guess I just understand better this time. This PR fixes 3 separate pointer invalidation problems, which are detected by running `MIRIFLAGS=-Zmiri-tag-raw-pointers cargo miri test`. Depending on how you squint, 2 or 3 of these are rust-lang/unsafe-code-guidelines#133. The last one is _probably_ still present even with late invalidation, because `set_len` does a write through a `&mut`. It's unclear to me if any of these things that Miri complains about are potentially a miscompilation in rustc due to the use of LLVM `noalias`. But perhaps given how subtle this codebase is overall, it would be best to run the tools on their pickiest settings, even if there are a few things more like a false positive than a real problem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the test suite only had one trip through the tail-shifting
code in Drain::drop, and that is in the heap state.
In the current implementation, a tail-shifting drain while in the inline
state produces potentially dangerous aliasing which is currently
accepted by default Miri and rejected with -Ztrack-raw-pointers.
Adding this test case ensures that if this ever becomes an actual
problem it will be easy to find.