From: Paul Floyd Date: Sat, 6 Sep 2025 11:52:47 +0000 (+0200) Subject: FreeBSD memalign wrapper: size of 0 now allowed X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3c7a8f435f7a1f5cc64c23c5f03348e0ce29a98e;p=thirdparty%2Fvalgrind.git FreeBSD memalign wrapper: size of 0 now allowed memalign, the random allocator function amongst allocators --- diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 9e0591abf..96edc5bfe 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1840,7 +1840,10 @@ extern int * __error(void) __attribute__((weak)); * * FreeBSD, undocumented, just calls aligned_alloc * with size rounded up to a multiple - * of aligment + * of aligment (unless the alignment is 0 in which case + * it just calls malloc [prior to Feb 2023 this wasn't + * handled correctly resulting in a division-by-zero crash + * in the size roundup code]) * * jemalloc mininum alignment is 1, must be a power of 2 * it looks like excessively large alignment causes ENOMEM @@ -1924,7 +1927,7 @@ extern int * __error(void) __attribute__((weak)); #define VG_MEMALIGN_NO_ALIGN_ZERO 0 #endif -#if defined(MUSL_LIBC) +#if defined(MUSL_LIBC) || defined(VGO_freebsd) #define VG_MEMALIGN_NO_SIZE_ZERO 0 #else #define VG_MEMALIGN_NO_SIZE_ZERO 1