]> sourceware.org Git - valgrind.git/commitdiff
Add checks to all new / delete overload arguments
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 7 Mar 2023 21:47:19 +0000 (22:47 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 7 Mar 2023 21:47:19 +0000 (22:47 +0100)
.gitignore
coregrind/m_replacemalloc/vg_replace_malloc.c
memcheck/tests/Makefile.am
memcheck/tests/sized_aligned_new_delete_args.cpp [new file with mode: 0644]
memcheck/tests/sized_aligned_new_delete_args.stderr.exp [new file with mode: 0644]
memcheck/tests/sized_aligned_new_delete_args.vgtest [new file with mode: 0644]

index 67e6b545fe32eadfb8d47723eb42d66c293554c7..a4c7b510bab152b629e4d195c9d98bdc1fa06e33 100644 (file)
 /memcheck/tests/sendmsg
 /memcheck/tests/sh-mem
 /memcheck/tests/sh-mem-random
+/memcheck/tests/sized_aligned_new_delete_args
 /memcheck/tests/sigaltstack
 /memcheck/tests/sigkill
 /memcheck/tests/signal2
index 6addfe80f9b9bdf0223e0264f20899d1a7b4f8dd..e07ab505047ae0146c3ea8f5dd0243a3da0222c2 100644 (file)
@@ -930,6 +930,19 @@ extern int *___errno (void) __attribute__((weak));
 
 /*---------------------- delete ----------------------*/
 
+#define DELETE_SIZED(soname, fnname, vg_replacement) \
+   \
+   void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size); \
+   void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size)  \
+   { \
+      DO_INIT; \
+      TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)size); \
+      MALLOC_TRACE(#fnname "(%p)\n", p ); \
+      if (p == NULL)  \
+         return; \
+      (void)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, p ); \
+   }
+
 #if defined(VGO_linux)
  // operator delete(void*), not mangled (for gcc 2.96)
  FREE(VG_Z_LIBSTDCXX_SONAME,   __builtin_delete,     __builtin_delete );
@@ -941,16 +954,16 @@ extern int *___errno (void) __attribute__((weak));
  FREE(SO_SYN_MALLOC,          _ZdlPv,               __builtin_delete );
  // operator delete(void*, unsigned int), C++14, GNU mangling
 #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvj,               __builtin_delete );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvj,               __builtin_delete );
FREE(VG_Z_LIBC_SONAME,       _ZdlPvj,               __builtin_delete );
FREE(SO_SYN_MALLOC,          _ZdlPvj,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvj,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBCXX_SONAME,     _ZdlPvj,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBC_SONAME,       _ZdlPvj,               __builtin_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdlPvj,               __builtin_delete );
  // operator delete(void*, unsigned long), C++14, GNU mangling
 #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvm,               __builtin_delete );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvm,               __builtin_delete );
FREE(VG_Z_LIBC_SONAME,       _ZdlPvm,               __builtin_delete );
FREE(SO_SYN_MALLOC,          _ZdlPvm,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvm,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBCXX_SONAME,     _ZdlPvm,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBC_SONAME,       _ZdlPvm,               __builtin_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdlPvm,               __builtin_delete );
 #endif
 
 
@@ -960,13 +973,13 @@ extern int *___errno (void) __attribute__((weak));
  FREE(SO_SYN_MALLOC,          _ZdlPv,               __builtin_delete );
  // operator delete(void*, unsigned long), C++14, GNU mangling
 #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvj,               __builtin_delete );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvj,               __builtin_delete );
FREE(SO_SYN_MALLOC,          _ZdlPvj,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvj,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBCXX_SONAME,     _ZdlPvj,               __builtin_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdlPvj,               __builtin_delete );
 #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvm,               __builtin_delete );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvm,               __builtin_delete );
FREE(SO_SYN_MALLOC,          _ZdlPvm,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvm,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBCXX_SONAME,     _ZdlPvm,               __builtin_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdlPvm,               __builtin_delete );
 #endif
 
 #elif defined(VGO_darwin)
@@ -981,11 +994,11 @@ extern int *___errno (void) __attribute__((weak));
 
  // operator delete(void*, unsigned long), C++14, GNU mangling
  #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvj,               __builtin_delete );
FREE(SO_SYN_MALLOC,          _ZdlPvj,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvj,               __builtin_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdlPvj,               __builtin_delete );
  #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvm,               __builtin_delete );
FREE(SO_SYN_MALLOC,          _ZdlPvm,               __builtin_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvm,               __builtin_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdlPvm,               __builtin_delete );
 #endif
 
 
@@ -993,43 +1006,70 @@ extern int *___errno (void) __attribute__((weak));
 
  /*------------------- C++17 delete aligned -------------------*/
 
+#define DELETE_ALIGNED(soname, fnname, vg_replacement) \
+   \
+   void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t alignment); \
+   void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t alignment)  \
+   { \
+      DO_INIT; \
+      TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)alignment); \
+      MALLOC_TRACE(#fnname "(%p)\n", p ); \
+      if (p == NULL)  \
+         return; \
+      (void)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, p ); \
+   }
+
+#define DELETE_SIZED_ALIGNED(soname, fnname, vg_replacement) \
+   \
+   void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size, size_t alignment); \
+   void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size, size_t alignment)  \
+   { \
+      DO_INIT; \
+      TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)size); \
+      TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)alignment); \
+      MALLOC_TRACE(#fnname "(%p)\n", p ); \
+      if (p == NULL)  \
+         return; \
+      (void)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, p ); \
+   }
+
 #if defined(VGO_linux)
  // operator delete(void*, std::align_val_t), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBC_SONAME,       _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBC_SONAME,       _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
  FREE(SO_SYN_MALLOC,          _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
 
  // operator delete(void*, unsigned int, std::align_val_t), GNU mangling
 #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBC_SONAME,       _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBC_SONAME,       _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
  // operator delete(void*, unsigned long, std::align_val_t), GNU mangling
 #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBC_SONAME,       _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBC_SONAME,       _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
 #endif
 
 #elif defined(VGO_freebsd)
  // operator delete(void*, std::align_val_t), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,          _ZdlPvSt11align_val_t,               __builtin_delete_aligned );
 
  // operator delete(void*, unsigned int, std::align_val_t), GNU mangling
 #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdlPvjSt11align_val_t,               __builtin_delete_aligned );
  // operator delete(void*, unsigned long, std::align_val_t), GNU mangling
 #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdlPvmSt11align_val_t,               __builtin_delete_aligned );
 #endif
 
 #elif defined(VGO_darwin)
@@ -1037,17 +1077,17 @@ extern int *___errno (void) __attribute__((weak));
 #elif defined(VGO_solaris)
 
  // operator delete(void*, std::align_val_t)
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvSt11align_val_t, __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdlPvSt11align_val_t, __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvSt11align_val_t, __builtin_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,          _ZdlPvSt11align_val_t, __builtin_delete_aligned );
 
  // operator delete(void*, unsigned int, std::align_val_t)
 #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvjSt11align_val_t, __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdlPvjSt11align_val_t, __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvjSt11align_val_t, __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdlPvjSt11align_val_t, __builtin_delete_aligned );
  // operator delete(void*, unsigned long, std::align_val_t)
  #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvmSt11align_val_t, __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdlPvmSt11align_val_t, __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdlPvmSt11align_val_t, __builtin_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdlPvmSt11align_val_t, __builtin_delete_aligned );
 #endif
 
 #endif
@@ -1083,25 +1123,25 @@ extern int *___errno (void) __attribute__((weak));
 
 #if defined(VGO_linux)
  // operator delete(void*, std::align_val_t, std::nothrow_t const&), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,    _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
FREE(VG_Z_LIBC_SONAME,      _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,         _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBCXX_SONAME,    _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBC_SONAME,      _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,         _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
 
  // no sized version of this operator
 
 #elif defined(VGO_freebsd)
  // operator delete(void*, std::align_val_t, std::nothrow_t const&), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,    _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,         _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBCXX_SONAME,    _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,         _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
 
 #elif defined(VGO_darwin)
 
 #elif defined(VGO_solaris)
  // operator delete(void*, std::align_val_t, std::nothrow_t const&), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
FREE(SO_SYN_MALLOC,         _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,         _ZdlPvSt11align_val_tRKSt9nothrow_t,  __builtin_delete_aligned );
 
  // no sized version of this operator
 
@@ -1122,16 +1162,16 @@ extern int *___errno (void) __attribute__((weak));
 
 // operator delete[](void*, unsigned long), C++14, GNU mangling
  #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvj,              __builtin_vec_delete );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvj,              __builtin_vec_delete );
FREE(VG_Z_LIBC_SONAME,       _ZdaPvj,              __builtin_vec_delete );
FREE(SO_SYN_MALLOC,          _ZdaPvj,              __builtin_vec_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvj,              __builtin_vec_delete );
DELETE_SIZED(VG_Z_LIBCXX_SONAME,     _ZdaPvj,              __builtin_vec_delete );
DELETE_SIZED(VG_Z_LIBC_SONAME,       _ZdaPvj,              __builtin_vec_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdaPvj,              __builtin_vec_delete );
 
  #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvm,              __builtin_vec_delete );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvm,              __builtin_vec_delete );
FREE(VG_Z_LIBC_SONAME,       _ZdaPvm,              __builtin_vec_delete );
FREE(SO_SYN_MALLOC,          _ZdaPvm,              __builtin_vec_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvm,              __builtin_vec_delete );
DELETE_SIZED(VG_Z_LIBCXX_SONAME,     _ZdaPvm,              __builtin_vec_delete );
DELETE_SIZED(VG_Z_LIBC_SONAME,       _ZdaPvm,              __builtin_vec_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdaPvm,              __builtin_vec_delete );
 #endif
 
 #elif defined(VGO_freebsd)
@@ -1141,13 +1181,13 @@ extern int *___errno (void) __attribute__((weak));
  FREE(SO_SYN_MALLOC,          _ZdaPv,               __builtin_vec_delete );
  // operator delete[](void*, unsigned long), C++14, GNU mangling
   #if __SIZEOF_SIZE_T__ == 4
-  FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvj,              __builtin_vec_delete );
-  FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvj,              __builtin_vec_delete );
-  FREE(SO_SYN_MALLOC,          _ZdaPvj,              __builtin_vec_delete );
+  DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvj,              __builtin_vec_delete );
+  DELETE_SIZED(VG_Z_LIBCXX_SONAME,     _ZdaPvj,              __builtin_vec_delete );
+  DELETE_SIZED(SO_SYN_MALLOC,          _ZdaPvj,              __builtin_vec_delete );
  #elif __SIZEOF_SIZE_T__ == 8
-  FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvm,              __builtin_vec_delete );
-  FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvm,              __builtin_vec_delete );
-  FREE(SO_SYN_MALLOC,          _ZdaPvm,              __builtin_vec_delete );
+  DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvm,              __builtin_vec_delete );
+  DELETE_SIZED(VG_Z_LIBCXX_SONAME,     _ZdaPvm,              __builtin_vec_delete );
+  DELETE_SIZED(SO_SYN_MALLOC,          _ZdaPvm,              __builtin_vec_delete );
  #endif
 
 #elif defined(VGO_darwin)
@@ -1165,12 +1205,12 @@ extern int *___errno (void) __attribute__((weak));
 
  // operator delete[](void*, unsigned int), C++14, GNU mangling
  #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvj,              __builtin_vec_delete );
FREE(SO_SYN_MALLOC,          _ZdaPvj,              __builtin_vec_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvj,              __builtin_vec_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdaPvj,              __builtin_vec_delete );
   // operator delete[](void*, unsigned long), C++14, GNU mangling
  #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvm,               __builtin_vec_delete );
FREE(SO_SYN_MALLOC,          _ZdaPvm,               __builtin_vec_delete );
DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvm,               __builtin_vec_delete );
DELETE_SIZED(SO_SYN_MALLOC,          _ZdaPvm,               __builtin_vec_delete );
 #endif
 
 #endif
@@ -1179,58 +1219,58 @@ extern int *___errno (void) __attribute__((weak));
 
 #if defined(VGO_linux)
  // operator delete[](void*, std::align_val_t), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBC_SONAME,       _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBC_SONAME,       _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,          _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
 
  // operator delete[](void*, unsigned int, std::align_val_t), GNU mangling
  #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBC_SONAME,       _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBC_SONAME,       _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
  // operator delete[](void*, unsigned long, std::align_val_t), GNU mangling
  #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBC_SONAME,       _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBC_SONAME,       _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
 #endif
 
 #elif defined(VGO_freebsd)
  // operator delete[](void*, std::align_val_t), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,          _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
 
  // operator delete[](void*, unsigned int, std::align_val_t), GNU mangling
  #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
  // operator delete[](void*, unsigned long, std::align_val_t), GNU mangling
  #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
 #endif
 
 #elif defined(VGO_darwin)
 
 #elif defined(VGO_solaris)
  // operator delete[](void*, std::align_val_t), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,          _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned );
 
  // operator delete[](void*, unsigned int, std::align_val_t)
  #if __SIZEOF_SIZE_T__ == 4
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned );
  // operator delete[](void*, unsigned long), GNU mangling
  #elif __SIZEOF_SIZE_T__ == 8
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
DELETE_SIZED_ALIGNED(SO_SYN_MALLOC,          _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned );
 #endif
 
 #endif
@@ -1266,25 +1306,25 @@ extern int *___errno (void) __attribute__((weak));
 
 #if defined(VGO_linux)
  // operator delete[](void*, std::align_val_t, std::nothrow_t const&), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBC_SONAME,       _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBC_SONAME,       _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,          _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
 
  // no sized version of this operator
 
 #elif defined(VGO_freebsd)
  // operator delete[](void*, std::align_val_t, std::nothrow_t const&), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
FREE(VG_Z_LIBCXX_SONAME,     _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBCXX_SONAME,     _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,          _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
 
 #elif defined(VGO_darwin)
 
 #elif defined(VGO_solaris)
  // operator delete[](void*, std::align_val_t, std::nothrow_t const&), GNU mangling
FREE(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
FREE(SO_SYN_MALLOC,          _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME,  _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
DELETE_ALIGNED(SO_SYN_MALLOC,          _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned );
 
  // no sized version of this operator
 
index 6c1c20185ab0b1e429ea8c4ddc91922e543f6d03..dc0f39aa6532f3c4cf944b1ec08414b7043a36a8 100644 (file)
@@ -139,6 +139,8 @@ EXTRA_DIST = \
        cxx17_aligned_new.stderr.exp cxx17_aligned_new.vgtest \
                cxx17_aligned_new.stderr.exp_32 \
                cxx17_aligned_new.stdout.exp \
+       sized_aligned_new_delete_args.stderr.exp \
+               sized_aligned_new_delete_args.vgtest \
        deep-backtrace.vgtest deep-backtrace.stderr.exp \
        demangle.stderr.exp demangle.vgtest \
        big_debuginfo_symbol.stderr.exp big_debuginfo_symbol.vgtest \
@@ -485,7 +487,7 @@ cdebug_zlib_gnu_CFLAGS = $(AM_CFLAGS) -g -gz=zlib-gnu @FLAG_W_NO_UNINITIALIZED@
 endif
 
 if HAVE_ALIGNED_CXX_ALLOC
-check_PROGRAMS += cxx17_aligned_new
+check_PROGRAMS += cxx17_aligned_new sized_aligned_new_delete_args
 endif
 
 if HAVE_PTHREAD_BARRIER
@@ -546,6 +548,8 @@ bug340392_CFLAGS        = $(AM_CFLAGS) -O3 @FLAG_W_NO_MAYBE_UNINITIALIZED@
 if HAVE_ALIGNED_CXX_ALLOC
 cxx17_aligned_new_SOURCES  = cxx17_aligned_new.cpp
 cxx17_aligned_new_CXXFLAGS = -std=c++17 @FLAG_W_NO_MISMATCHED_NEW_DELETE@
+sized_aligned_new_delete_args_SOURCES = sized_aligned_new_delete_args.cpp
+sized_aligned_new_delete_args_CXXFLAGS = -std=c++17
 endif
 
 demangle_SOURCES = demangle.cpp
diff --git a/memcheck/tests/sized_aligned_new_delete_args.cpp b/memcheck/tests/sized_aligned_new_delete_args.cpp
new file mode 100644 (file)
index 0000000..a8d5024
--- /dev/null
@@ -0,0 +1,42 @@
+#include <cstdlib>
+#include <new>
+#include <iostream>
+#include "../memcheck.h"
+
+int main() {
+    std::align_val_t align(static_cast<std::align_val_t>(64U));
+    std::align_val_t uninitalign(static_cast<std::align_val_t>(64U));
+    size_t uninitsize(16);
+    size_t size(16);
+    std::nothrow_t tag;
+    void *mem;
+    VALGRIND_MAKE_MEM_UNDEFINED(&uninitsize, sizeof(uninitsize));
+    VALGRIND_MAKE_MEM_UNDEFINED(&uninitalign, sizeof(uninitalign));
+    
+    mem = operator new(uninitsize, uninitalign);
+    operator delete(mem, uninitalign);
+    
+    mem = operator new[](uninitsize, uninitalign);
+    operator delete[](mem, uninitalign);
+    
+    // doesn't matter that tag is uninit
+    // don't want to see an error
+    mem = operator new(uninitsize, uninitalign, tag);
+    operator delete(mem, uninitalign, tag);
+
+    mem = operator new[](uninitsize, uninitalign, tag);
+    operator delete[](mem, uninitalign, tag);
+    
+    mem = operator new(size);
+    operator delete(mem, uninitsize);
+    
+    mem = operator new[](size);
+    operator delete[](mem, uninitsize);
+    
+    mem = operator new(size, align);
+    operator delete(mem, uninitsize, uninitalign);
+    
+    mem = operator new[](size, align);
+    operator delete[](mem, uninitsize, uninitalign);
+}
+
diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp
new file mode 100644 (file)
index 0000000..c086f1d
--- /dev/null
@@ -0,0 +1,83 @@
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete(void*, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete[](void*, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete[](void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: ...operator delete... (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete[](void*, unsigned long) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+   by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args)
+
+
+HEAP SUMMARY:
+    in use at exit: 0 bytes in 0 blocks
+  total heap usage: 8 allocs, 8 frees, 128 bytes allocated
+
+For a detailed leak analysis, rerun with: --leak-check=full
+
+Use --track-origins=yes to see where uninitialised values come from
+For lists of detected and suppressed errors, rerun with: -s
+ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0)
diff --git a/memcheck/tests/sized_aligned_new_delete_args.vgtest b/memcheck/tests/sized_aligned_new_delete_args.vgtest
new file mode 100644 (file)
index 0000000..8df8db4
--- /dev/null
@@ -0,0 +1,2 @@
+prog: sized_aligned_new_delete_args
+prereq: test -e ./sized_aligned_new_delete_args
This page took 0.065 seconds and 5 git commands to generate.