Skip to content

Commit 00fd712

Browse files
committed
add some general Stacked Borrows concerns
1 parent 8d6c4e6 commit 00fd712

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

resources/deliberate-ub.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ We should evaluate whether there truly is some use-case here that is not current
3535
This could be fixed by [`MaybeDangling`](https://github.com/rust-lang/rfcs/pull/3336).
3636
* The entire `async fn` ecosystem and every hand-implemented self-referential generator or future is unsound since the self-reference aliases the `&mut` reference to the full generator/future.
3737
This is currently hackfixed by making `Unpin` meaningful for UB; a proper solution would be to add something like [`UnsafeAliased`](https://github.com/rust-lang/rfcs/pull/3467).
38+
* Stacked Borrows forbids a bunch of things that might be considered too restrictive (and that go well beyond LLVM `noalias`):
39+
strict subobject provenance [rules out the `&Header` pattern](https://github.com/rust-lang/unsafe-code-guidelines/issues/256) and also affects [raw pointers derived from references](https://github.com/rust-lang/unsafe-code-guidelines/issues/134);
40+
eager assertion of uniquess makes [even read-only functions such as `as_mut_ptr` dangerous when they take `&mut`](https://github.com/rust-lang/unsafe-code-guidelines/issues/133);
41+
`&UnsafeCell` surprisingly [requires read-write memory even when it is never written](https://github.com/rust-lang/unsafe-code-guidelines/issues/303).
42+
There is a bunch of code out there that violates these rules one way or another.
43+
All of these are resolved by [Tree Borrows](https://perso.crans.org/vanille/treebor/), though [some subtleties around `as_mut_ptr` do remain](https://github.com/rust-lang/unsafe-code-guidelines/issues/450).
3844

3945
## Former cases of deliberate UB that have at least a work-in-progress solution to them
4046

0 commit comments

Comments
 (0)