Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> All RAM access is deterministic in the sense that the value will not change until written.

Again, the article literally points to how this is not true given modern allocators. The memory that Linux exposes to processes will change without being written to prior to being initialized given how allocators manage it. This isn't a fiction of the C-standard or rust reference, it's what actually happens in the real world on a regular basis.

Rust is not confused, it is correctly observing what is allowed to actually happen to uninitialized memory while the process does nothing to it.

You could change the C/Rust specification of that memory. You could in your C/rust implementation declare that the OS swapping out pages of uninitialized memory counts as a write just like any other, and that it's the programmers (allocators) responsibility to make sure those writes obey the normal aliasing rules. Doing so would be giving up performance though, because the fact that writing to memory has the side-effect of cancelling collection of freed pages is a powerful way for processes to quickly communicate with the OS. (You'd probably also cause other issues with memory mapped IO, values after the end of the stack changing, and so on, but we can just focus on this one issue for now).



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

Search: