From: Paul Floyd Date: Mon, 28 Oct 2024 19:36:17 +0000 (+0100) Subject: Bug 495469 - aligned_alloc and posix_memalign missing MALLOC_TRACE with returned... X-Git-Tag: VALGRIND_3_24_0~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f29bc61a22097c4e5ca966ad874647ef596f0327;p=thirdparty%2Fvalgrind.git Bug 495469 - aligned_alloc and posix_memalign missing MALLOC_TRACE with returned pointer --- diff --git a/NEWS b/NEWS index 74679b34c..8fb685ffa 100644 --- a/NEWS +++ b/NEWS @@ -83,6 +83,8 @@ are not entered into bugzilla tend to get forgotten about or ignored. 494252 s390x: incorrect disassembly for LOCHI and friends 495278 PowerPC instruction dcbf should allow the L field values of 4, 6 on ISA 3.0 and earlier, just ignore the value +495469 aligned_alloc and posix_memalign missing MALLOC_TRACE with returned + pointer n-i-bz Improve messages for sigaltstack errors, use specific stack_t member names diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index c8f93bc42..4125479b8 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1781,6 +1781,7 @@ extern int * __error(void) __attribute__((weak)); MALLOC_TRACE("reallocarray(%p,%llu,%llu)", ptrV, (ULong)nmemb, (ULong)size ); \ if (nmemb > 0 && (SizeT)-1 / nmemb < size) { \ SET_ERRNO_ENOMEM; \ + MALLOC_TRACE(" = 0\n"); \ return NULL; \ } \ v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_realloc, ptrV, nmemb*size ); \ @@ -1987,6 +1988,7 @@ extern int * __error(void) __attribute__((weak)); (alignment & (alignment - 1)) != 0) || \ (VG_MEMALIGN_ALIGN_FACTOR_FOUR && (alignment % 4 != 0))) { \ SET_ERRNO_EINVAL; \ + MALLOC_TRACE(" = 0\n"); \ return 0; \ } \ /* Round up to minimum alignment if necessary. */ \ @@ -2006,6 +2008,8 @@ extern int * __error(void) __attribute__((weak)); if (!mem) \ SET_ERRNO_ENOMEM; \ \ + MALLOC_TRACE(" = %p\n", mem); \ + \ return mem; \ } @@ -2049,6 +2053,8 @@ extern int * __error(void) __attribute__((weak)); \ if (!mem) SET_ERRNO_ENOMEM; \ \ + MALLOC_TRACE(" = %p\n", mem); \ + \ return mem; \ } @@ -2188,12 +2194,14 @@ extern int * __error(void) __attribute__((weak)); if (alignment == 0 \ || alignment % sizeof (void *) != 0 \ || (alignment & (alignment - 1)) != 0) { \ + MALLOC_TRACE(" = 0\n"); \ return VKI_EINVAL; \ } \ if (VG_POSIX_MEMALIGN_SIZE_0_RETURN_NULL && \ size == 0U) { \ /* no allocation for zero size on Solaris/Illumos */ \ *memptr = NULL; \ + MALLOC_TRACE(" = 0\n"); \ return 0; \ } \ /* Round up to minimum alignment if necessary. */ \ @@ -2203,6 +2211,8 @@ extern int * __error(void) __attribute__((weak)); mem = (void*)VALGRIND_NON_SIMD_CALL3( info.tl_memalign, \ alignment, orig_alignment, size ); \ \ + MALLOC_TRACE(" = %p\n", mem); \ + \ if (mem != NULL) { \ *memptr = mem; \ return 0; \ @@ -2328,6 +2338,8 @@ extern int * __error(void) __attribute__((weak)); mem = (void*)VALGRIND_NON_SIMD_CALL3( info.tl_memalign, \ alignment, orig_alignment, size ); \ \ + MALLOC_TRACE(" = %p\n", mem); \ + \ return mem; \ } @@ -2353,6 +2365,7 @@ extern int * __error(void) __attribute__((weak)); || (VG_ALIGNED_ALLOC_ALIGN_POWER_TWO && (alignment & (alignment - 1)) != 0) \ || (VG_ALIGNED_ALLOC_ALIGN_FACTOR_FOUR && (alignment % 4 != 0))) { \ SET_ERRNO_EINVAL; \ + MALLOC_TRACE(" = 0\n"); \ return 0; \ } \ \ @@ -2367,6 +2380,8 @@ extern int * __error(void) __attribute__((weak)); \ if (!mem) SET_ERRNO_ENOMEM; \ \ + MALLOC_TRACE(" = %p\n", mem); \ + \ return mem; \ } #endif