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

            Bug ID: 452072
           Summary: false positive from wmemcmp_avx2_movbe (glibc-2.34 or
                    later?)
           Product: valgrind
           Version: 3.18.1
          Platform: Fedora RPMs
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: memcheck
          Assignee: jsew...@acm.org
          Reporter: takimot...@kba.biglobe.ne.jp
  Target Milestone: ---

Created attachment 147840
  --> https://bugs.kde.org/attachment.cgi?id=147840&action=edit
output of "valgrind -v ./a.out"

SUMMARY
wmemcmp(s1, s2, n) gives false positive even if n is smaller than the allocated
size of s1 and s2

STEPS TO REPRODUCE
1. compile the following C source (test.c):

#include <stdlib.h>
#include <wchar.h>
int main()  {
    wchar_t *a, *b;
    int ret;
    a = (wchar_t*)calloc(3, sizeof(wchar_t));
    b = (wchar_t*)calloc(3, sizeof(wchar_t));
    ret = wmemcmp(a, b, 2);
    free(a);
    free(b);
    return ret;
}

2. valgrind ./a.out

OBSERVED RESULT
Invalid read of size 32
   at 0x49EB499: __wmemcmp_avx2_movbe (memcmp-avx2-movbe.S:412)
   by 0x40118B: main (test.c:8)
 Address 0x4a75090 is 0 bytes inside a block of size 12 alloc'd
   at 0x4849464: calloc (vg_replace_malloc.c:1328)
   by 0x40116F: main (test.c:7)

Output of 'valglind -v ./a.out' is in log.txt.

EXPECTED RESULT
no error

SOFTWARE/OS VERSIONS
Fedora-35

ADDITIONAL INFORMATION
CPU is x86_64 with AVX2.
Fedora-35 uses glibc-2.34.
Same problem in the latest Arch Linux (glibc-2.35),
but no problem in Fedora-34 (glibc-2.33).

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to