Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
Posted Mar 25, 2022 14:11 UTC (Fri) by darthscsi (guest, #8111)In reply to: Beingessner: Rust's Unsafe Pointer Types Need An Overhaul by jlombera
Parent article: Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
The problem here is cache coherence is a broad term and what different architectures do is vastly different. Multithreaded or multiprocess code expose the cache coherence semantics of the architecture to the programmer. This is not true for single threaded coded. Programmers, especially x86 programmers, try to extrapolate what cache coherence does from single threaded execution, which is not a correct thing to do. Volatile effective forces the compiler to make loads and stores (but doesn't order volatile and non-volatile accesses, which is why old code had the iconic empty asm block marked as writing all memory), but it does nothing to protect you from the architecture's memory model. x86 has a strong memory model, which has fewer classes of behavior which don't match single threaded code, if you constrain the compiler, but that doesn't mean they don't exist, the ISA has locked prefixes for a number of instructions for a reason.
