]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Disable memcpy overlap check and test on amd64 linux
authorMark Wielaard <mark@klomp.org>
Mon, 30 Oct 2023 22:30:06 +0000 (23:30 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 30 Oct 2023 22:30:06 +0000 (23:30 +0100)
Almost all newer distros have ifunc based memcpy/memmove glibc
implementation which cause false positives. Disable the overlap check
and test on these systems for now.

https://bugs.kde.org/show_bug.cgi?id=402833

memcheck/tests/overlap.vgtest
shared/vg_replace_strmem.c

index 54a0baacfb7b336b2ff39506436dc1b6abdf1c31..eba65897cd8151515a61e0c2544277b06a02b7d6 100644 (file)
@@ -1,2 +1,4 @@
 prog: overlap
 vgopts: -q
+# https://bugs.kde.org/show_bug.cgi?id=402833
+prereq: ! ../../tests/arch_test amd64
index 8de6a0698eb3da6e98e2733a2ad42b6287ac9a28..79e640189f2e11ee2bfcb3f16f5dae04b011d74e 100644 (file)
@@ -1128,8 +1128,15 @@ static inline void my_exit ( int x )
 #define MEMMOVE(soname, fnname)  \
    MEMMOVE_OR_MEMCPY(20181, soname, fnname, 0)
 
-#define MEMCPY(soname, fnname) \
+/* See https://bugs.kde.org/show_bug.cgi?id=402833
+   why we disable the overlap check on x86_64.  */
+#if defined(VGP_amd64_linux)
+ #define MEMCPY(soname, fnname) \
+   MEMMOVE_OR_MEMCPY(20180, soname, fnname, 0)
+#else
+ #define MEMCPY(soname, fnname) \
    MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1)
+#endif
 
 #if defined(VGO_linux)
  /* For older memcpy we have to use memmove-like semantics and skip
@@ -1704,6 +1711,14 @@ static inline void my_exit ( int x )
 
 /*-------------------- memcpy_chk --------------------*/
 
+/* See https://bugs.kde.org/show_bug.cgi?id=402833
+   why we disable the overlap check on x86_64.  */
+#if defined(VGP_amd64_linux)
+ #define CHECK_OVERLAP 0
+#else
+ #define CHECK_OVERLAP 1
+#endif
+
 #define GLIBC26___MEMCPY_CHK(soname, fnname) \
    void* VG_REPLACE_FUNCTION_EZU(20300,soname,fnname) \
             (void* dst, const void* src, SizeT len, SizeT dstlen ); \
@@ -1717,7 +1732,7 @@ static inline void my_exit ( int x )
       RECORD_COPY(len); \
       if (len == 0) \
          return dst; \
-      if (is_overlap(dst, src, len, len)) \
+      if (CHECK_OVERLAP && is_overlap(dst, src, len, len)) \
          RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \
       if ( dst > src ) { \
          d = (HChar *)dst + len - 1; \