Bug 23188 - Process record does not support instruction 0xc5 (vmovd %esi,%xmm0 / AVX2)
Summary: Process record does not support instruction 0xc5 (vmovd %esi,%xmm0 / AVX2)
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: record (show other bugs)
Version: 8.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2018-05-16 14:20 UTC by Peter Wu
Modified: 2022-07-05 17:45 UTC (History)
6 users (show)

See Also:
Last reconfirmed: 2019-04-11 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Peter Wu 2018-05-16 14:20:26 UTC
Reverse debugging using the "record" command halts when it encounters an AVX2-related instruction.

(gdb) record full
(gdb) c
Process record does not support instruction 0xc5 at address 0x7fffddca0010.
Process record: failed to record execution log.

0x00007fffddca0010 in __memset_avx2_unaligned_erms () from /usr/lib/libc.so.6
(gdb) x/i $rip
=> 0x7fffddca0010 <__memset_avx2_unaligned_erms>:       vmovd  %esi,%xmm0

As a workaround, libc can be patched to hide the AVX2 CPU feature, but it is rather cumbersome to use: https://stackoverflow.com/q/42451492

Affects glibc 2.24, 2.25, 2.27 on Arch Linux and Ubuntu.
CPU: i7-6700HQ
Comment 1 Nathaniel M. Beaver 2018-09-29 00:28:34 UTC
Maybe a duplicate of #17346?

Comment 2 Peter Wu 2018-09-29 08:57:24 UTC
Not a duplicate, the bug 17346 is about AVX while this one is about AVX2. The other would be a good starting point for this one I suppose.
Comment 3 Jan Engelhardt 2019-01-17 10:29:36 UTC
#include <string.h>
int main(int argc, char **argv)
        return strcasecmp(argv[0], "foooooooooooooooooooooooooooobaaaar") == 0;

(gcc 7.4.0)
$ gcc-7 t.c -ggdb3
$ gdb a.out 
GNU gdb (GDB; openSUSE Tumbleweed) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) b main
Breakpoint 1 at 0x401126: file t.c, line 4.
(gdb) r
Starting program: a.out 

Breakpoint 1, main (argc=1, argv=0x7fffffffde68) at t.c:4
4               return strcasecmp(argv[0], "foooooooooooooooooooooooooooobaaaar") == 0;
(gdb) record
(gdb) c
Process record does not support instruction 0xc5 at address 0x7ffff7b7134f.

[1]+  Stopped                 gdb a.out
$ fg
gdb a.out
Process record: failed to record execution log.

Program stopped.
__strcasecmp_l_avx () at ../sysdeps/x86_64/multiarch/strcmp-sse42.S:187
187             movdqa  LABEL(belowupper)(%rip), %xmm4
(gdb) disas
Dump of assembler code for function __strcasecmp_l_avx:
   0x00007ffff7b71330 <+0>:     mov    (%rdx),%rax
   0x00007ffff7b71333 <+3>:     testl  $0x1,0x278(%rax)
   0x00007ffff7b7133d <+13>:    jne    0x7ffff7abaca0 <__strcasecmp_l_nonascii>
   0x00007ffff7b71343 <+19>:    mov    %esi,%ecx
   0x00007ffff7b71345 <+21>:    mov    %edi,%eax
   0x00007ffff7b71347 <+23>:    and    $0x3f,%rcx
   0x00007ffff7b7134b <+27>:    and    $0x3f,%rax
=> 0x00007ffff7b7134f <+31>:    vmovdqa 0x2f649(%rip),%xmm4        # 0x7ffff7ba09a0
   0x00007ffff7b71357 <+39>:    vmovdqa 0x2f661(%rip),%xmm5        # 0x7ffff7ba09c0
   0x00007ffff7b7135f <+47>:    vmovdqa 0x2f629(%rip),%xmm6        # 0x7ffff7ba0990 <blanks>
   0x00007ffff7b71367 <+55>:    cmp    $0x30,%ecx
   0x00007ffff7b7136a <+58>:    ja     0x7ffff7b713d0 <__strcasecmp_l_avx+160>
   0x00007ffff7b7136c <+60>:    cmp    $0x30,%eax
   0x00007ffff7b7136f <+63>:    ja     0x7ffff7b713d0 <__strcasecmp_l_avx+160>
   0x00007ffff7b71371 <+65>:    vmovdqu (%rdi),%xmm1
   0x00007ffff7b71375 <+69>:    vmovdqu (%rsi),%xmm2
   0x00007ffff7b71379 <+73>:    vpcmpgtb %xmm4,%xmm1,%xmm7
   0x00007ffff7b7137d <+77>:    vpcmpgtb %xmm5,%xmm1,%xmm8
   0x00007ffff7b71381 <+81>:    vpcmpgtb %xmm4,%xmm2,%xmm9
   0x00007ffff7b71385 <+85>:    vpcmpgtb %xmm5,%xmm2,%xmm10
   0x00007ffff7b71389 <+89>:    vpandn %xmm7,%xmm8,%xmm8
   0x00007ffff7b7138d <+93>:    vpandn %xmm9,%xmm10,%xmm10
   0x00007ffff7b71392 <+98>:    vpand  %xmm6,%xmm8,%xmm8
Comment 4 Alan Hayward 2019-04-11 07:49:49 UTC
Using HEAD, on Ubuntu 16.04 X86-64 I get this error many times when running gdb.reverse/sigall-reverse.exp

make check "RUNTESTFLAGS=gdb.reverse/sigall-reverse.exp"
# of expected passes		424
# of unexpected failures	493
# of expected failures		71

Snippet from gdb.log:

(gdb) PASS: gdb.reverse/sigall-reverse.exp: b gen_TTIN
Process record does not support instruction 0xc5 at address 0x7ffff7dee8b7.^M
Process record: failed to record execution log.^M
(gdb) FAIL: gdb.reverse/sigall-reverse.exp: get signal CHLD
Process record does not support instruction 0xc5 at address 0x7ffff7dee8b7.^M
Process record: failed to record execution log.^M

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial

$ cat /proc/version
Linux version 4.4.0-121-generic (buildd@lcy01-amd64-004) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9) ) #145-Ubuntu SMP Fri Apr 13 13:47:23 UTC 2018
Comment 5 Sourceware Commits 2019-09-27 08:36:59 UTC
The master branch has been updated by Tom de Vries <vries@sourceware.org>:


commit 68f7d34dd506d1ccdaab9e772a533f8e76a5fe19
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Sep 27 10:36:18 2019 +0200

    [gdb/testsuite] Add KFAIL for missing support of reverse-debugging of vmovd
    On my openSUSE Leap 15.1 system I run into:
    (gdb) PASS: gdb.reverse/step-precsave.exp: turn on process record
    break 76^M
    Breakpoint 2 at 0x400654: file step-reverse.c, line 76.^M
    (gdb) PASS: gdb.reverse/step-precsave.exp: breakpoint at end of main
    Process record does not support instruction 0xc5 at address 0x7ffff783fc70.^M
    Process record: failed to record execution log.^M
    Program stopped.^M
    0x00007ffff783fc70 in __memset_avx2_unaligned_erms () from /lib64/libc.so.6^M
    (gdb) FAIL: gdb.reverse/step-precsave.exp: run to end of main
    The problem is that the vmovd instruction is not supported in
    reverse-debugging (PR record/23188).
    Add a KFAIL for this PR.
    Tested on x86_64-linux.
    2019-09-27  Tom de Vries  <tdevries@suse.de>
    	PR record/23188
    	* gdb.reverse/step-precsave.exp: Add kfail for PR record/23188.
Comment 6 Peter Wu 2020-02-06 22:54:00 UTC
The problem still exists in GDB 8.3.1.
A workaround for typical programs is described in https://stackoverflow.com/q/42451492/427545

Bug 19365 is about AVX while this bug is about AVX2.

Full AVX/AVX2 support looks like a ton of work:
- At minimum VEX prefix support (C4 for 3-byte VEX, C5 for 2-byte VEX) [1]
- AVX-specific instructions [2] - currently not supported.
- AVX2-specific instructions [3] - currently not supported.

Luckily AVX-512 is not common yet, the full set of extensions is quite big.[4]

It looks like i386_process_record in i386-tdep.c has to be updated to support new features. For the original case (vmovd), support for the VEX prefixes (the 'v' in 'vmovd') should be sufficient.

 [1]: https://en.wikipedia.org/wiki/VEX_prefix
 [2]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#New_instructions
 [3]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#New_instructions_2
 [4]: https://en.wikipedia.org/wiki/AVX-512