3 ms·
That's a VM feature. I mean, yes, if you change your process's memory space between accesses you break whatever the compiler might have assumed. You don't nee
by ajross 2y ago
That's a VM feature. I mean, yes, if you change your process's memory space between accesses you break whatever the compiler might have assumed. You don't need fancy flags, either! Just, y'know, munmap() will do.
This is yet another unrelated tangent. Can you explain why it it you think the presence of MADV_FREE disallows Rust from allowing writes to uninitialized memory?
- db48x 2y agoYou’re missing the point. It doesn't matter that this is a VM feature and not a hardware feature. The fact that it exists at all means that reading from uninitialized memory is unsound. You can write to it all you want, but not read from it.
- ajross 2y agoOnce more, the use case in question is WRITING to uninitialized memory, not reading from it. Rust is applying the constraints of the latter (and thus requiring "unsafe") to the former, which is not an unsafe operation.
- gpm 2y agoNo. Rust is only applying any constraints to reading from it. The entire discussion is how to make an API which defines which portions of the memory can be read from because they have been written to, so we can expose an API that cannot be misused. There have never been any constraints on writing to uninitialized memory.