Avoid Box invalidation to be compatible with tag-raw-pointers #1166
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.
It looks like the only outstanding issue aliasing issue in this repo
(with raw pointer tagging) was this one move of a Box after saving a
pointer to the allocation that the Box guards. This is UB according to
the Stacked Borrows with raw pointer tagging in combination with the way
rustc applies noalias to Box. As is often the case, the resolution here
is to convert the Box down to a raw pointer before a pointer into the
allocation is created.
It is unclear to me if the spec will change and make this code valid without this PR. In rust-lang/unsafe-code-guidelines#326 I've advocated for removing this special property from
Box
altogether. But by the same token, it's entirely possible that this code is UB today because it does aliased access through anoalias
pointer. I don't know if the access toentries.len()
is problematic aliasing with thegroup_up
pointer.