Skip to content

Replace dodgy pointer operations#17

Merged
yvt merged 11 commits intomainfrom
fix-dodgy-ptr-ops
Nov 27, 2025
Merged

Replace dodgy pointer operations#17
yvt merged 11 commits intomainfrom
fix-dodgy-ptr-ops

Conversation

@yvt
Copy link
Copy Markdown
Owner

@yvt yvt commented Nov 22, 2025

Makes the code compliant with the current aliasing model. Fixes #9.

Remaining Issues

Limitations

…ll_slice_len`

> [..] because [..] there might be outstanding mutable references to the
> slice.

<https://doc.rust-lang.org/reference/behavior-considered-undefined.html>

> The exact aliasing rules are not determined yet, but here is an
> outline of the general principles: `&T` must point to memory that is
> not mutated while they are live (except for data inside an
> `UnsafeCell<U>`),
Comment thread crates/rlsf/src/utils.rs Outdated
yvt added 9 commits November 23, 2025 11:57
Because of how this polyfill is implemented, it can only be used on a
dereferencable pointer. It does not need to be initialized (owing to
`UnsafeCell`) or immuable (owing to `MaybeUninit`).
`&mut self.pool[$expr]` would invalidate the previously returned slice
pointer.
…s_block`

`&BlockHdr` lacks permission to access the next `BlockHdr`, which
`BlockHdr::next_phys_block` returns.
A borrowed `*BlockHdr` lacks permission to access the adjacent blocks.
Get a raw pointer to a specific field and read or write to it instead of
borrowing a whole `{Free,Used}BlockHdr` unless it is known to be fully
initialized.
…ange

`ShadowAllocator::remove_pool` needs a dereferencable slice pointer to
get its length because `<*const [T]>::len` is not stable yet in the
MSRV.
A pointer created from `pool.0[0]` only has permission for `pool.0[0]`,
not whole `pool.0`.
@yvt yvt force-pushed the fix-dodgy-ptr-ops branch from 856f619 to 9be6e88 Compare November 23, 2025 02:57
@yvt yvt marked this pull request as ready for review November 23, 2025 09:44
@yvt yvt merged commit 88ecd76 into main Nov 27, 2025
6 checks passed
@yvt yvt deleted the fix-dodgy-ptr-ops branch November 27, 2025 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Miri compatibility

2 participants