From: Mark Wielaard Date: Thu, 26 Oct 2023 10:25:44 +0000 (+0200) Subject: vg_replace_malloc DELETE should not check size X-Git-Tag: VALGRIND_3_22_0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8b6ee6b5f5efbd759c87fa987e9149800db2899;p=thirdparty%2Fvalgrind.git vg_replace_malloc DELETE should not check size The DELETE replacement functions check the size argument, but this doesn't actually exist. Only the DELETE_SIZED replacement functions get a size (and should check it). On i386 (fedora gnu/linux) this causes the following failures: memcheck/tests/cxx17_aligned_new (stderr) memcheck/tests/leak_cpp_interior (stderr) memcheck/tests/mismatches (stderr) memcheck/tests/mismatches_xml (stderr) memcheck/tests/new_aligned_delete_default (stderr) memcheck/tests/new_nothrow (stderr) memcheck/tests/realloc_size_zero_mismatch (stderr) All showing "size" being undefined: +Conditional jump or move depends on uninitialised value(s) + at 0x........: ...operator delete[]... (vg_replace_malloc.c:...) or +Mismatched new/delete size value: 4 + at 0x........: ...operator delete... (vg_replace_malloc.c:...) Oddly no other architecture seems to show issues. Maybe we just got lucky? This patch fixes the issues on i386 (and shows no regressions on x86_64) https://bugs.kde.org/show_bug.cgi?id=476108 --- diff --git a/NEWS b/NEWS index 7d64208243..5a388464e2 100644 --- a/NEWS +++ b/NEWS @@ -89,6 +89,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 474332 aligned_alloc under Valgrind returns nullptr when alignment is not a multiple of sizeof(void *) 475650 DRD does not work with C11 threads 475652 Missing suppression for __wcsncpy_avx2 (strncpy-avx2.S:308)? +476108 vg_replace_malloc DELETE checks size n-i-bz Allow arguments with spaces in .valgrindrc files n-i-bz FreeBSD fixed reading of Valgrind tools own debuginfo diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index e238a52f36..7859f5f325 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1027,13 +1027,12 @@ extern int * __error(void) __attribute__((weak)); #define DELETE(soname, fnname, vg_replacement, tag) \ \ - void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT size); \ - void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT size) \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p); \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p) \ { \ struct AlignedAllocInfo aligned_alloc_info = { .mem=p, .alloc_kind=AllocKind##tag }; \ \ DO_INIT; \ - TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)size); \ VERIFY_ALIGNMENT(&aligned_alloc_info); \ MALLOC_TRACE(#fnname "(%p)\n", p ); \ if (p == NULL) \