{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreievung42o24r6z3oxciaqzaeqq5vyzkr5sakyiljwzpzeskznm7ma",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mluamozw6vo2"
},
"path": "/t/include-racy-reads-in-rust-memory-model-with-maybeinvalid-t/24289#post_19",
"publishedAt": "2026-05-15T00:05:51.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "I just had an opsem idea about this: have a racy-read primitive that (from the opsem point of view) simply remembers the \"time\" at which it is called (defined in the usual not-fully-ordered concurrent way) and the address on which it was called (storing the time/address in an opaque object), plus a second primitive that (when given the opaque object) returns what the value of the memory was at that past time (with undefined behavior if a read then would have raced). This is similar in concept to `MaybeUninit` and `assume_init`, but formalized differently (so that if the read would have raced, it technically never occurred).\n\nThis opsem doesn't invaliate any optimisations that LLVM currently implements (nor that LLVM can implement in the future without changing its memory model), and the form of time travel involved is conceptually easy to understand (because it is talking purely about past events). I also don't think it requires any changes to the memory model. (At the hardware level, it's also fairly easy to implement by doing a hardware-level read and storing the result of that in the opaque object, assuming you are using hardware on which a racing read produces an undefined value rather than being hardware-level undefined behavior.)",
"title": "Include racy reads in Rust memory model with `MaybeInvalid<T>`"
}