Fix Miri errors for WindowsIter and ExactChunksIter/Mut#1142
Merged
bluss merged 1 commit intorust-ndarray:masterfrom Mar 9, 2024
Merged
Fix Miri errors for WindowsIter and ExactChunksIter/Mut#1142bluss merged 1 commit intorust-ndarray:masterfrom
bluss merged 1 commit intorust-ndarray:masterfrom
Conversation
Before this commit, running `MIRIFLAGS="-Zmiri-tag-raw-pointers" cargo miri test` caused Miri to report undefined behavior for code using the `WindowsIter`, `ExactChunksIter`, and `ExactChunksIterMut` iterators. This commit fixes the underlying issue. Basically, Miri doesn't like code which uses a reference to an element to access other elements. Before this commit, these iterators wrapped the `ElementsBase` and `ElementsBaseMut` iterators, and they created views from the references returned by those inner iterators. Accessing elements within those views (other than the first element) led to the Miri error, since the view's pointer was derived from a reference to a single element. Now, the iterators wrap `Baseiter` instead, which produces raw pointers instead of references. Although not necessary to satisfy Miri, this commit also changes the `Windows`, `ExactChunks`, and `ExactChunksMut` producers to wrap raw views instead of normal views. This avoids potential confusion regarding which elements are accessible through the views produced by these producers.
97c00b9 to
6df86a3
Compare
Member
|
rebased. Safety delayed is safety denied.. yet we try to merge it now. Thanks for the nice work. I had to do some conflict resolution on this one around where the |
Member
|
cc @adamreichold if you are interested in miri, there are instructions here |
bluss
approved these changes
Mar 9, 2024
Closed
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.
Before this PR, running
MIRIFLAGS="-Zmiri-tag-raw-pointers" cargo miri testcaused Miri to report undefined behavior for code using theWindowsIter,ExactChunksIter, andExactChunksIterMutiterators. This PR fixes the underlying issue. Basically, Miri doesn't like code which uses a reference to an element to access other elements. Before this PR, these iterators wrapped theElementsBaseandElementsBaseMutiterators, and they created views from the references returned by those inner iterators. Accessing elements within those views (other than the first element) led to the Miri error, since the view's pointer was derived from a reference to a single element. Now, the iterators wrapBaseiterinstead, which produces raw pointers instead of references.Although not necessary to satisfy Miri, this PR also changes the
Windows,ExactChunks, andExactChunksMutproducers to wrap raw views instead of normal views. This avoids potential confusion regarding which elements are accessible through the views produced by these producers.With this PR, #1138, and bluss/matrixmultiply#67,
MIRIFLAGS="-Zmiri-tag-raw-pointers -Zmiri-check-number-validity" RUSTFLAGS="-Zrandomize-layout" cargo +nightly miri testruns without errors (in about 8 minutes on my machine).