This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug string/23196] New: __mempcpy_avx512_no_vzeroupper mishandles large copies


https://sourceware.org/bugzilla/show_bug.cgi?id=23196

            Bug ID: 23196
           Summary: __mempcpy_avx512_no_vzeroupper mishandles large copies
           Product: glibc
           Version: 2.23
            Status: NEW
          Severity: normal
          Priority: P2
         Component: string
          Assignee: unassigned at sourceware dot org
          Reporter: schwab@linux-m68k.org
  Target Milestone: ---
            Target: x86_64-*-*

If __mempcpy_avx512_no_vzeroupper has to copy a large buffer it always writes
128 bytes past the end of the buffer.

$ cat mempcpy.c
#define _GNU_SOURCE 1
#include <string.h>
#include <assert.h>

#define N 97699
char a[N];
char b[N+128];

int
main (void)
{
  memset (a, 'x', N);
  char *c = mempcpy (b, a, N);
  assert (*c == 0);
}
$ gcc -g mempcpy.c -o mempcpy -fno-builtin-mempcpy
$ ./mempcpy 
mempcpy: mempcpy.c:14: main: Assertion `*c == 0' failed.

The problem is these two lines in memmove-avx512-no-vzeroupper.S:

        vmovups %zmm4, (%rax)
        vmovups %zmm5, 0x40(%rax)

For mempcpy, %rax points to the end of the buffer.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]