New comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34030#issuecomment-1002300676 Comment: It's looking like a bug in musl `posix_memalign()` ```c $ cat a.c #include #include #include int main(int argc, char ** argv) { int res; void * memptr = (void *)0xbadbeef; long size = 1L<<20; struct rlimit r = { 1L<<20, -1 }; if (argc > 1) size = atol(argv[1]); if (argc > 2) r.rlim_cur = atol(argv[2]); printf("memptr = %p, size = %ld, limit = %ld\n", memptr, size, r.rlim_cur); setrlimit(RLIMIT_AS, &r); res = posix_memalign(&memptr, size, 64); printf("res = %d, memptr = %p\n", res, memptr); return 0; } $ cc a.c -o a && ./a memptr = 0xbadbeef, size = 1048576, limit = 1048576 Segmentation fault ``` The expected behaviour from `posix_memalign(3p)` is: ``` RETURN VALUE Upon successful completion, posix_memalign() shall return zero; otherwise, an error number shall be returned to indicate the error and the contents of memptr shall either be left unmodified or be set to a null pointer. ``` Edit: my code is ok as you can see if you change the rlimit so that enough memory is available: ``` $ ./a $[2**20] $[2**21] memptr = 0xbadbeef, size = 1048576, limit = 2097152 res = 0, memptr = 0x7feab0d00000 ``` OTOH if you ask for a much larger amount of memory, it fails as expected (12 is ENOMEM) ``` $ ./a $[2**35] $[2**20] memptr = 0xbadbeef, size = 34359738368, limit = 1048576 res = 12, memptr = 0xbadbeef ```