From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 943C53857400; Fri, 8 Mar 2024 04:10:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 943C53857400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709871009; bh=guvORSXwacZh0+tFO1W09yrFu5FQn7ZH220jPm7y9kM=; h=From:To:Subject:Date:From; b=qmZLAkKmFQv9ndVWMZtiK7s1tYjifBkXsyQ/HoNVdftZl9oneT934WF9amD+y1t00 3Mv/6d7P6TfZVYKldASGuL4cZ+J4+Mkj9aT+QSBk0xi5gkP89mVQiG95+kiIzxpdsD l+R8mOWHwgIMJk3XFBXS2tdQ2qOosZNLm9+3XgBw= From: "elrodc at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114276] New: Trapping on aligned operations when using vector builtins + `-std=gnu++23 -fsanitize=address -fstack-protector-strong` Date: Fri, 08 Mar 2024 04:10:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: elrodc at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114276 Bug ID: 114276 Summary: Trapping on aligned operations when using vector builtins + `-std=3Dgnu++23 -fsanitize=3Daddress -fstack-protector-strong` Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: elrodc at gmail dot com Target Milestone: --- Created attachment 57651 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D57651&action=3Dedit test file I'm not sure how to categorize the issue, so I picked "target" as it occurs= for x86_64 when using aligned moves on 64-byte avx512 vectors. `-std=3Dc++23` also reproduces the problem. I am using: > g++ --version > g++ (GCC) 13.2.1 20231205 (Red Hat 13.2.1-6) > Copyright (C) 2023 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOS= E. The attached file is: > #include > #include >=20 > template > using Vec [[gnu::vector_size(W * sizeof(T))]] =3D T; >=20 > auto foo() { > Vec<8, int64_t> ret{}; > return ret; > } >=20 > int main() { > foo(); > return 0; > } I have attached this file. On a skylake-avx512 CPU, I get > g++ -std=3Dgnu++23 -march=3Dskylake-avx512 -fstack-protector-strong -O0 -= g -mprefer-vector-width=3D512 -fsanitize=3Daddress,undefined -fsanitize-tra= p=3Dall simdvecalign.cpp && ./a.out AddressSanitizer:DEADLYSIGNAL =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D36238=3D=3DERROR: AddressSanitizer: SEGV on unknown address (pc 0x000= 00040125c bp 0x7ffdf88a1cb0 sp 0x7ffdf88a1bc0 T0) =3D=3D36238=3D=3DThe signal is caused by a READ memory access. =3D=3D36238=3D=3DHint: this fault was caused by a dereference of a high val= ue address (see register values below). Disassemble the provided pc to learn which register was used. #0 0x40125c in foo() /home/chriselrod/Documents/progwork/cxx/experiments/simdvecalign.cpp:8 #1 0x4012d1 in main /home/chriselrod/Documents/progwork/cxx/experiments/simdvecalign.cpp:13 #2 0x7f296b846149 in __libc_start_call_main (/lib64/libc.so.6+0x28149) (BuildId: 7ea8d85df0e89b90c63ac7ed2b3578b2e7728756) #3 0x7f296b84620a in __libc_start_main_impl (/lib64/libc.so.6+0x2820a) (BuildId: 7ea8d85df0e89b90c63ac7ed2b3578b2e7728756) #4 0x4010a4 in _start (/home/chriselrod/Documents/progwork/cxx/experiments/a.out+0x4010a4) (Build= Id: 765272b0173968b14f4306c8d4a37fcb18733889) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /home/chriselrod/Documents/progwork/cxx/experiments/simdvecalign.cpp:8 in f= oo() =3D=3D36238=3D=3DABORTING fish: Job 1, './a.out' terminated by signal SIGABRT (Abort) However, if I remove any of `-std=3Dgnu++23`, `-fsantize=3Daddress`, or `-fstack-protector-strong`, the code runs without a problem. Using 32 byte vectors instead of 64 byte also allows it to work. I also used `-S` to look at the assembly. When I edit the two lines: > vmovdqa64 %zmm0, -128(%rdx) > .loc 1 9 10 > vmovdqa64 -128(%rdx), %zmm0 swapping `vmovdqa64` for `vmovdqu64`, the code runs as intended. > g++ -fsanitize=3Daddress simdvecalign.s # using vmovdqu64 > ./a.out > g++ -fsanitize=3Daddress simdvecalign.s # reverted back to vmovdqa64 > ./a.out AddressSanitizer:DEADLYSIGNAL =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D40364=3D=3DERROR: AddressSanitizer: SEGV on unknown address (pc 0x000= 00040125c bp 0x7ffd2e2dc240 sp 0x7ffd2e2dc140 T0) so I am inclined to think that something isn't guaranteeing that `%rdx` is actually 64-byte aligned (but it may be 32-byte aligned, given that I can't reproduce with 32 byte vectors).=