points by 0xdeafbeef 4 days ago | 0 comments
"void*" sadly exists, and there are a lot of edge cases.
I tried using TCMalloc with rustc, and it segfaulted. Rust knows the sizes of its allocations, but things can still go wrong at the allocator boundary.
Size should be an optimization hint, not a correctness requirement. Otherwise, it's just another security pitfall
[–] OskarS 4 days ago
[–] 0xdeafbeef 4 days ago
https://github.com/microsoft/mimalloc/issues/1423
https://github.com/microsoft/mimalloc/issues/1400
And there also bugs for zig. So hint - fine. Trust it? Not sure. Every allocator is different and can be swapped
[–] SkiFire13 4 days ago
> "void*" sadly exists
But _somewhere_ you need to know what it represents, otherwise it's useless.
> I tried using TCMalloc with rustc, and it segfaulted. Rust knows the sizes of its allocations, but things can still go wrong at the allocator boundary.
Things can go wrong, doesn't mean they will go wrong due to the reasons you're thinking of.
[0]: https://www.lua.org/manual/5.4/manual.html#lua_Alloc