On Wed, Dec 17, 2025 at 01:03:27PM +0000, Seth McDonald wrote: > G'day (or night, as I'm writing this),
G'day Seth! > On Tuesday, 16 December 2025 at 00:41, Alejandro Colomar <[email protected]> > wrote: > > Hi! > > Since nobody complained about patches 1..13, I've pushed them. I'll continue work on patch 14. > > > In v2, I've removed the explicit sentence saying that one should use > > aligned_alloc(3) instead of memalign(3). > > > > > I've also documented that C11 had a bogus specification for > > aligned_alloc(3), and that OpenBSD still implements that (although at > > least, they don't exploit the UB). I've CCed them, in case they're not > > aware that C17 fixed those issues. > > > > > I've documented that while the C11 specification had a lot of UB, no > > implementation has ever implemented that, and so it's just theoretical > > (and thankfully extinct) UB. > > I had a look at FreeBSD's documentation for aligned_alloc(3) - which is > just jemalloc's manual - and it does explicitly specify the C11 > undefined behaviour.[1] > > "The aligned_alloc() function allocates size bytes of memory such that > the allocation's base address is a multiple of alignment. The requested > alignment must be a power of 2. Behavior is undefined if size is not an > integral multiple of alignment." > > However, I have spent a while going over FreeBSD's (jemalloc's) > implementation of aligned_alloc(3), and as far as I can tell, it > appears to work as expected even when size is not a multiple of > alignment. So it seems the man page is just repeating the C11 standard > to conform to it (though the page doesn't specify this conformance, > strangely enough). > > Even so, it may be useful to also document FreeBSD's nominal undefined > behaviour in addition to OpenBSD. Perhaps emphasising how jemalloc > doesn't actually exploit this undefined behaviour, and never will given > the project's recent retirement. Thereby meaning the point about C11's > extinct undefined behaviour should still stand. > > This would also prevent people (like myself, I imagine) from thinking > that the Linux man page is potentially outdated due to seemingly not > knowing about FreeBSD's (ostensible, but documented) undefined > behaviour. Thanks! I'll send a revised patch in a moment. Have a lovely day! Alex -- <https://www.alejandro-colomar.es>
signature.asc
Description: PGP signature

