From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B85FA385840F; Thu, 24 Mar 2022 21:57:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B85FA385840F From: "amonakov at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug tdep/28999] New: amd64_get_insn_details wrong for some AVX instructions Date: Thu, 24 Mar 2022 21:57:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: tdep X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amonakov at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot 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 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2022 21:57:15 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28999 Bug ID: 28999 Summary: amd64_get_insn_details wrong for some AVX instructions Product: gdb Version: unknown Status: UNCONFIRMED Severity: normal Priority: P2 Component: tdep Assignee: unassigned at sourceware dot org Reporter: amonakov at gmail dot com Target Milestone: --- Trying breakpointing on 'f' in typedef unsigned char u8v16 __attribute__((vector_size(16))); __attribute__((weak)) u8v16 f(void) { return (u8v16){-1}; } int main() { f(); } which gcc -O2 -mavx compiles to f: vmovdqa .LC0(%rip), %xmm0 ret you'll see that 'cont' or 'si' after hitting the breakpoint results in SIGS= EGV, even though the program is correct and runs just fine without the breakpoin= t.=20 Printing $_siginfo is not helpful, but the reason for the segfault is that behind the scenes vmovdqa is moved to another address, but its RIP-relative displacement field is unchanged: (gdb) set debug displaced on (gdb) c Continuing. displaced: stepping process 29476 now displaced: saved 0x401002: f9 6f 05 f7 0f 00 00 0f 0b 00 00 00 00 00 00 00 displaced: copy 0x401001->0x401002: c5 f9 6f 05 f7 0f 00 00 0f 0b 00 00 00 = 00 00 00 displaced: displaced pc to 0x401002 displaced: run 0x401002: c5 f9 6f 05 displaced: restored process 29476 0x401002 Program received signal SIGSEGV, Segmentation fault. If you hand-edit the assembly, replacing 'vmovdqa' with 'movdqa' or 'movaps= ', gdb correctly detects presence of RIP-relative addressing. The logic in amd64_get_insn_details is such that after skipping any prefixe= s, including the VEX prefix, it looks up presence of ModRM field via the onebyte_has_modrm table, but this opcode map from year 1999 is not applicab= le if VEX prefix was present. In other circumstances, the breakpointed instruction could have allowed unaligned access, and would read/write wrong data instead of segfaulting, l= ike in this bugreport: https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/18502= 58. Happy debugging! --=20 You are receiving this mail because: You are on the CC list for the bug.=