"accessible" terminology in with_exposed_provenance docs is misleading
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
During stabilization, we changed the documentation of exposed provenance from saying that memory outside the AM "is always exposed" to "is always accessible". Based on a conversation I just had, I believe the new documentation to be wrong, because it suggests that this program is permitted:
use std::ptr;
fn main() {
// Create a byte we "magically" know the address of (by capturing it)
// Another way to stash or know a valid-to-write address would make a better demo.
let mut byte = 0u8;
let magic_addr = &mut byte as *mut u8 as usize;
let func = |r: &mut u8| {
*r = 123;
unsafe {
// The docs say:
// memory which is outside the control of the Rust abstract machine
// (MMIO registers, for example) is always considered to be accessible
// with an exposed provenance
// So this address should be accessible, according to the docs.
// But the access here is a clear violation of the noalias attribute.
dbg!(*ptr::with_exposed_provenance::<u8>(magic_addr))
}
};
let ptr = ptr::with_exposed_provenance_mut::<u8>(magic_addr);
unsafe {
func(&mut *ptr);
}
}
The current documentation can be traced to this part of the stabilization PR discussion: https://github.com/rust-lang/rust/pull/130350#issuecomment-2369169477
I am writing this up as I am heading to bed, so please just correct me if I seem wrong. cc @rust-lang/opsem
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the with_exposed_provenance documentation and read the linked stabilization PR discussion, especially the cited comment. Determine whether “accessible” accurately describes exposed provenance in the example, then update the terminology or clarify the docs so the permitted behavior and aliasing implications are unambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100