]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
vg_replace_malloc DELETE should not check size
authorMark Wielaard <mark@klomp.org>
Thu, 26 Oct 2023 10:25:44 +0000 (12:25 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 26 Oct 2023 10:35:26 +0000 (12:35 +0200)
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

NEWS
coregrind/m_replacemalloc/vg_replace_malloc.c

diff --git a/NEWS b/NEWS
index 7d6420824337f5c029d0800972f1e1a40f64d00e..5a388464e26b6ff8988e39a14167d1da64786775 100644 (file)
--- 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
 
index e238a52f3675113acc28c437d35f6e7f433bd43d..7859f5f3250e99bc24573d626f2a054694e18f51 100644 (file)
@@ -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)  \