|
Message-ID: <CAJgzZoo4Xd67UVnTGNtBTD8y-tVMGkjKYb0vRgNFczu4e9T9ZA@mail.gmail.com> Date: Thu, 27 Jun 2024 17:31:03 -0400 From: enh <enh@...gle.com> To: libc-coord@...ts.openwall.com, Zijun Zhao <zijunzhao@...gle.com> Subject: aligned_realloc() zijunzhao is working on adding _FORTIFY_SOURCE=3 to bionic, and hitting the same malloc_usable_size() issues that i think glibc did. interestingly, there seem to be two main use cases: (a) keeping statistics about native heap allocations [where there's really no workaround, and we just need to build that file with _FORTIFY_SOURCE=2, because the functions for reporting heap usage will include _all_ allocations, not just the ones they're trying to track] and (b) implementing an "aligned_realloc()". C23 doesn't say anything about alignment when describing realloc(). it might be nice to assume that "The realloc function deallocates the old object pointed to by ptr and returns a pointer to a new object that has the size specified by size" actually means "The realloc function deallocates the old object pointed to by ptr and returns a pointer to a new object that has the size specified by size, and the same alignment that the old object had", since that's presumably what anyone making the call means, but i don't even know what our allocator does. i see MS has an _aligned_realloc(), allegedly because their malloc()/free() allocator couldn't support user-requested alignment, so they added a whole parallel set of functions [with a leading underscore] instead of C11's aligned_realloc(). has anyone noticed this before? there are some pretty unfortunate limitations in all the attempts to implement this outside of libc that i've seen. (although i haven't seen anyone go this route yet, i suspect an mmap()/mremap() implementation would be the least worst ... except it would be Linux-only.)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.