Skip to content

Commit c004f3a

Browse files
authored
Merge pull request #544 from RalfJung/deliberate-ub
deliberate UB: OOB access
2 parents 7a295dc + a92a7d6 commit c004f3a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

resources/deliberate-ub.md

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ We should evaluate whether there truly is some use-case here that is not current
3434
There is a bunch of code out there that violates these rules one way or another.
3535
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).
3636

37+
### Other cases
38+
39+
* `gxhash` wants to do a vector-sized load that may go out-of-bounds, and didn't find a better solution than causing UB with an OOB load and then masking off the extra bytes.
40+
See [here](https://github.com/ogxd/gxhash/issues/82) for some discussion and [here](https://github.com/ogxd/gxhash/blob/9eb19b021ff94a7b37beb5f479880d07e029b933/src/gxhash/platform/mod.rs#L18) for the relevant code.
41+
The same [also happens in `compiler-builtins`](https://github.com/rust-lang/compiler-builtins/issues/559).
42+
3743
## Former cases of deliberate UB that have at least a work-in-progress solution to them
3844

3945
* Various `offset_of` implementations caused UB by using `mem::uninitialized()`, or they used `&(*base).field` or `addr_of!((*base).field)` to project a dummy pointer to the field which is UB due to out-of-bounds pointer arithmetic.

0 commit comments

Comments
 (0)