https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128433
Bug ID: 128433
Summary: overread causes segfault inmasked vect epilogue
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: linkw at gcc dot gnu.org
Target Milestone: ---
Test case:
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
__attribute__ ((noinline, noclone))
static void
copy_float (const float *s, float *d, long n)
{
for (long i = 0; i < n; ++i)
{
d[2 * i] = s[i];
d[2 * i + 1] = s[i];
}
}
int
main (void)
{
long page = sysconf (_SC_PAGESIZE);
char *memory = mmap (0, 2 * page, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (memory == MAP_FAILED
|| mprotect (memory + page, page, PROT_NONE))
abort ();
volatile long count = 1;
float *s = (float *) (memory + page - count * sizeof (*s));
float d[2] = { 0, 0 };
s[0] = 1;
copy_float (s, d, count);
if (d[0] != 1 || d[1] != 1)
abort ();
return 0;
}
machine: x86-64 with avx512f support
Option: -Ofast -march=znver4
// pass by disabling avx512_masked_epilogues by
-mtune-ctrl=^avx512_masked_epilogues