3 ms·
If two threads independently mmap the same file, what is the thing that Rust forces them to synchronize on?
by ridiculous_fish 10y ago
If two threads independently mmap the same file, what is the thing that Rust forces them to synchronize on?
- steveklabnik 10y agommap can't be exposed with a safe interface, in my understanding.
- Manishearth 10y agoOf course, you can access `/proc/self/mem` safely so technically it's all possible in safe code. But that's not something Rust can prevent.
- notriddle 10y agoThat's a known bug: https://github.com/rust-lang/rust/issues/32670 https://github.com/rust-lang/rust/issues/32670 This bug was posted on April 1st, being a bit more ha-ha-only-serious than the emoji-based error handling one that the core team put on. AFAIK, it's the only WONTFIX safety bug in Rust's issue tracker.
- burntsushi 10y agoThe de facto memmap crate for Rust makes it unsafe to access the contents of a memory map: https://docs.rs/memmap/0.5.0/memmap/struct.Mmap.html#method.as_slice https://docs.rs/memmap/0.5.0/memmap/struct.Mmap.html#method.... This doesn't actually answer your question, but the presence of `unsafe` will at least warn you that you need to put some thought into what you're doing.