4 ms·
What does safe mean here? Everything can be interpreted as a [u8], right?
by MrBuddyCasino 2y ago
What does safe mean here? Everything can be interpreted as a [u8], right?
- lidavidm 2y agohttps://www.ralfj.de/blog/2019/07/14/uninit.html https://www.ralfj.de/blog/2019/07/14/uninit.html perhaps (the OP also talks about this when linking to a talk about jemalloc)
- MrBuddyCasino 2y agoInteresting. Tl;dr: its not to do with any hardware concept, the compiler can substitute any value for a read of uninitialised memory, and the value does not have to be stable.
- gpm 2y ago[u8] guarantees to the compiler that two reads through the array at the same location without any intervening writes return the same value. Turns out that's not the case on freshly returned uninitiated allocations. The first read could return old data (say "1"), and the second read could return a freshly zeroed page ("0").
- ridiculous_fish 2y agoNo, it's not so. If the allocation is backed by the kernel, then it will be zero-filled for security reasons. If it's backed by user-space malloc then who knows; but there's never a scenario where a mallocated page is quietly replaced by a zero-filled page behind the scenes.
- gpm 2y agoCtrl-f tautology in the article, it turns out that is not the case because of madvise free.