Hacker News new | past | comments | ask | show | jobs | submit login

Not if the memory has been allocated on a shared memory segment, Rust has no control over what other processes might do.



Sound Rust code would either make functions touching the shared memory marked unsafe, or would do a defensive copy out of shared memory.


That safe layer around unsafe still has no way to validate the consistency of the data.


It can't proactively validate the data while it's in the shared memory.

If you do your validation during accesses it's fine. If you copy the data out of the shared memory it's fine.

Or you could use a mutex to protect the data between validation and use.

If you're worried about another process editing the memory without taking the mutex, that's equivalent to worrying about other unsafe code editing the memory without taking the mutex. The solution is the same in both place: don't share memory with completely arbitrary code. When people compare languages and techniques, they (rightfully) assume you're not doing that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: