From: Paul Floyd Date: Thu, 20 Apr 2023 20:11:31 +0000 (+0200) Subject: Bug 397083 - Likely false positive "uninitialised value(s)" for __wmemchr_avx2 and... X-Git-Tag: VALGRIND_3_21_0~36 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=a2af9adec4536c3ce95d4ea5ddf15d00d7c55c6c;p=valgrind.git Bug 397083 - Likely false positive "uninitialised value(s)" for __wmemchr_avx2 and __wmemcmp_avx2_movbe --- diff --git a/.gitignore b/.gitignore index 6622e7c59e..9e26e2fbf5 100644 --- a/.gitignore +++ b/.gitignore @@ -1004,6 +1004,7 @@ /memcheck/tests/wcs /memcheck/tests/weirdioctl /memcheck/tests/with space +/memcheck/tests/wmemcmp /memcheck/tests/wrap1 /memcheck/tests/wrap2 /memcheck/tests/wrap3 diff --git a/NEWS b/NEWS index 4ba0c31709..57e39f42a3 100644 --- a/NEWS +++ b/NEWS @@ -126,6 +126,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 351857 confusing error message about valid command line option 374596 inconsistent RDTSCP support on x86_64 392331 Spurious lock not held error from inside pthread_cond_timedwait +397083 Likely false positive "uninitialised value(s)" for __wmemchr_avx2 and __wmemcmp_avx2_movbe 400793 pthread_rwlock_timedwrlock false positive 419054 Unhandled syscall getcpu on arm32 433873 openat2 syscall unimplemented on Linux diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index b4d80f837a..faf9130bcd 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -376,6 +376,7 @@ EXTRA_DIST = \ vcpu_fnfns.stdout.exp-darwin vcpu_fnfns.stdout.exp-solaris \ vcpu_fnfns.stderr.exp vcpu_fnfns.vgtest \ wcs.vgtest wcs.stderr.exp wcs.stdout.exp \ + wmemcmp.vgtest wmemcmp.stderr.exp \ wrap1.vgtest wrap1.stdout.exp wrap1.stderr.exp \ wrap2.vgtest wrap2.stdout.exp wrap2.stderr.exp \ wrap3.vgtest wrap3.stdout.exp wrap3.stderr.exp \ @@ -478,6 +479,7 @@ check_PROGRAMS = \ vcpu_fbench vcpu_fnfns \ wcs \ xml1 \ + wmemcmp \ wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap7so.so wrap8 \ wrapmalloc wrapmallocso.so wrapmallocstatic \ writev1 diff --git a/memcheck/tests/wmemcmp.c b/memcheck/tests/wmemcmp.c new file mode 100644 index 0000000000..d737620094 --- /dev/null +++ b/memcheck/tests/wmemcmp.c @@ -0,0 +1,17 @@ +#include +#include + +int main () +{ + wchar_t *s = (wchar_t *) malloc (8 * sizeof (wchar_t)); + s[0] = '-'; + s[1] = 'N'; + s[2] = 'A'; + s[3] = 'N'; + s[4] = ' '; + s[5] = '3'; + s[6] = '3'; + s[7] = '\0'; + return wmemcmp (s + 1, L"NAN", 3) == 0; +} + diff --git a/memcheck/tests/wmemcmp.stderr.exp b/memcheck/tests/wmemcmp.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/wmemcmp.vgtest b/memcheck/tests/wmemcmp.vgtest new file mode 100644 index 0000000000..637a2335c0 --- /dev/null +++ b/memcheck/tests/wmemcmp.vgtest @@ -0,0 +1,2 @@ +prog: wmemcmp +vgopts: -q diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index 30065d537a..b32f13f76d 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -104,6 +104,7 @@ 20440 WCSNLEN 20450 WSTRNCMP 20460 MEMMEM + 20470 WMEMCMP */ #if defined(VGO_solaris) @@ -2262,6 +2263,26 @@ static inline void my_exit ( int x ) #if defined(VGO_freebsd) WMEMCHR(VG_Z_LIBC_SONAME, wmemchr) #endif + + +#define WMEMCMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20470,soname,fnname) \ + ( const Int *b1, const Int *b2, SizeT n ); \ + int VG_REPLACE_FUNCTION_EZU(20470,soname,fnname) \ + ( const Int *b1, const Int *b2, SizeT n ) \ + { \ + for (SizeT i = 0U; i < n; ++i) { \ + if (b1[i] != b2[i]) \ + return b1[i] > b2[i] ? 1 : -1; \ + } \ + return 0; \ + } + +#if defined(VGO_linux) + WMEMCMP(VG_Z_LIBC_SONAME, wmemcmp) +#endif + + /*------------------------------------------------------------*/ /*--- Improve definedness checking of process environment ---*/ /*------------------------------------------------------------*/