Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/ptr: Add simulate_realloc() #130886

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrkajetanp
Copy link
Contributor

@mrkajetanp mrkajetanp commented Sep 26, 2024

Add a simulate_realloc() helper function to core/ptr to simulate
reallocating memory from a pointer to some arbitrary address.
The function is intended to be used with architecture features such as
AArch64 Top-Byte Ignore where two different 64-bit addresses can point
to the same chunk of memory due to some bits being ignored.

To make the function accurately simulate an allocator, its return value
needs to be annotated with noalias in LLVM the same way as it is done
by actual allocator functions. To make that possible, add a new rustc
built-in attribute rustc_simulate_allocator that does the annotating.

Accompanying implementation for RFC 3700, currently posted on Rust Internals.

r? @RalfJung

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 26, 2024
@rust-log-analyzer

This comment has been minimized.

@mrkajetanp
Copy link
Contributor Author

This is just a reference PR for the RFC and the implementation is aarch64-specific hence the test failures. The question I hope the RFC process answers is whether the best approach would be to have a generic method like this with cfgs to choose between variants for different architectures hidden inside, or whether it should just be completely architecture-specific and put away in core_arch so that the users themselves have to opt-in to each architecture and/or tagging scheme they want to support.

@RalfJung
Copy link
Member

I'm afraid I don't have the capacity to shepherd this. Anyway it's blocked on the RFC.

r? libs

@rustbot rustbot assigned Mark-Simulacrum and unassigned RalfJung Sep 26, 2024
Add a `simulate_realloc()` helper function to core/ptr to simulate
reallocating memory from a pointer to some arbitrary address.
The function is intended to be used with architecture features such as
AArch64 Top-Byte Ignore where two different 64-bit addresses can point
to the same chunk of memory due to some bits being ignored.

To make the function accurately simulate an allocator, its return value
needs to be annotated with `noalias` in LLVM the same way as it is done
by actual allocator functions. To make that possible, add a new rustc
built-in attribute `rustc_simulate_allocator` that does the annotating.
@mrkajetanp mrkajetanp changed the title core: ptr: Add helpers for pointer tagging core/ptr: Add simulate_realloc() Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants