Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1450992

Summary: i386 record: Missing AVX; some gdb tests stopped working with new rhel-7.4 kernel
Product: Red Hat Enterprise Linux 8 Reporter: Martin Cermak <mcermak>
Component: gdbAssignee: Keith Seitz <keiths>
gdb sub component: system-version QA Contact: qe-baseos-tools-bugs
Status: CLOSED UPSTREAM Docs Contact:
Severity: unspecified    
Priority: unspecified CC: anprice, dimhen, dsmith, el, gdb-bugs, jan.kratochvil, mcermak, mkolar, mnewsome, ohudlick, palves, pzhukov, sergiodj, twaugh
Version: ---Keywords: FutureFeature
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-03 18:51:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1136403    
Bug Blocks:    
Attachments:
Description Flags
reproducer file taken from the GDB testsuite
none
libstring.c
none
glibc nomulti.patch none

Description Martin Cermak 2017-05-15 14:17:56 UTC
Michal Kolar noticed that some of the gdb tests do not PASS with new rhel-7.4 kernel, whereas they were passing with rhel-7.3 kernel.  The behaviour, however, is the same with both rhel-7.3 gdb and rhel-7.4 gdb when run on otherwise the same system, so it doesn't seem to be a regression of GDB as such, but rather a testcase sensitivity to the rhel version.

An example of such testcase is gdb.reverse/sigall-reverse.exp.  When the gdb-7.6.1-99.el7 version of this testcase gets run on top of rhel-7.3, the result is as follows:

=======
# of expected passes            950
=======

When running the same testcase on top of rhel-7.4, the result is as follows:

=======
# of expected passes            424
# of unexpected failures        493
# of expected failures          71
=======

The problem seems well reproducible. I can attach the dejagnu logs on demand.  I've been trying to follow the testcase scenario by hand and check for differences.  Here is what I've found for RHEL-7.3:

=======
 7.3 Server x86_64 # gcc -g -lm /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c
 7.3 Server x86_64 # gdb ./a.out 
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7
Copyright (C) 2013 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-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/a.out...done.
(gdb) b gen_ABRT
Breakpoint 1 at 0x400980: file /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c, line 384.
(gdb) run
Starting program: /root/./a.out 

Breakpoint 1, gen_ABRT () at /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c:384
384       kill (getpid (), SIGABRT);
Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7.x86_64
(gdb) record
(gdb) b handle_ABRT
Breakpoint 2 at 0x400704: file /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c, line 28.
(gdb) b gen_HUP
Breakpoint 3 at 0x40099c: file /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c, line 392.
(gdb) continue
Continuing.

Program received signal SIGABRT, Aborted.
0x00007ffff774f4a7 in kill () from /lib64/libc.so.6
(gdb)
=======

Here is analogical scenario replayed on rhel-7.4:

=======
 7.4 Server x86_64 # gcc -g -lm /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c
 7.4 Server x86_64 # gdb ./a.out
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-99.el7
Copyright (C) 2013 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-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/a.out...done.
(gdb) b gen_ABRT
Breakpoint 1 at 0x400980: file /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c, line 384.
(gdb) run
Starting program: /root/./a.out 

Breakpoint 1, gen_ABRT () at /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c:384
384       kill (getpid (), SIGABRT);
Missing separate debuginfos, use: debuginfo-install glibc-2.17-194.el7.x86_64
(gdb) record
(gdb) b handle_ABRT
Breakpoint 2 at 0x400704: file /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c, line 28.
(gdb) b gen_HUP
Breakpoint 3 at 0x40099c: file /root/rpmbuild/BUILD/gdb-7.6.1/gdb/testsuite/gdb.reverse/sigall-reverse.c, line 392.
(gdb) continue
Continuing.
Process record does not support instruction 0xc5 at address 0x7ffff7df06d7.
Process record: failed to record execution log.

[process 25327] #1 stopped.
0x00007ffff7df06d7 in _dl_runtime_resolve_avx () from /lib64/ld-linux-x86-64.so.2
(gdb) 
=======

The difference is that on rhel-7.4 I am getting this:

=======
Process record does not support instruction 0xc5 at address 0x7ffff7df06d7.
Process record: failed to record execution log.
=======

RPM Versions:
 7.3 Server: kernel-3.10.0-514.el7.x86_64, gcc-4.8.5-11.el7.x86_64, binutils-2.25.1-22.base.el7.x86_64
 7.4 Server: kernel-3.10.0-663.el7.x86_64, gcc-4.8.5-14.el7.x86_64, binutils-2.25.1-27.base.el7.x86_64

Please, review.

Comment 1 Martin Cermak 2017-05-15 14:18:33 UTC
Created attachment 1279010 [details]
reproducer file taken from the GDB testsuite

Comment 2 Jan Kratochvil 2017-05-15 14:27:59 UTC
That is a longterm problem of GDB that its support of instruction sets for recording is lacking behind new Intel processors.  glibc does use all the new instructions for minor optimizations of its functions like memcpy(3).

I guess detection of the new instructions by glibc may depend on Linux kernel version but I have no technical information about that.

It is up to someone whether GDB support of all latest instruction sets for recording is a supported feature or not.  It is not so difficult to extend/fix it, one needs to write down the opcodes coding of all the new instructions.

Comment 5 Jan Kratochvil 2017-09-04 14:56:35 UTC
Created attachment 1321885 [details]
libstring.c

gcc -o src/libstring.so src/libstring.c -Wall -g -shared -fPIC -O2
gdb -ex 'set env LD_BIND_NOW=1' -ex "set env LD_PRELOAD=$HOME/src/libstring.so" -ex start -ex record -ex c --args PROG ARGS

Comment 6 Jan Kratochvil 2017-09-04 15:11:00 UTC
But then it will stop anyway for example at:
Process record and replay target doesn't support syscall number 318
30	  return SYSCALL_CANCEL (getrandom, buffer, length, flags);
https://sourceware.org/bugzilla/show_bug.cgi?id=22081

Comment 7 Jan Kratochvil 2017-09-28 17:09:55 UTC
*** Bug 1136403 has been marked as a duplicate of this bug. ***

Comment 12 ell1e 2020-03-01 20:47:50 UTC
This seems to be a problem with current libc.so.6 in Fedora 31 with gdb 8.3 with basic string functions

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

Program stopped.
0x00007ffff7167849 in __strlen_avx2 () from /lib64/libc.so.6
(gdb)

Is there any workaround for this as an end user?

Comment 13 Sergio Durigan Junior 2020-03-02 16:43:09 UTC
(In reply to Ellie from comment #12)
> This seems to be a problem with current libc.so.6 in Fedora 31 with gdb 8.3
> with basic string functions
> 
> (gdb) record
> (gdb) c
> Continuing.
> Process record does not support instruction 0xc5 at address 0x7ffff7167849.
> Process record: failed to record execution log.
> 
> Program stopped.
> 0x00007ffff7167849 in __strlen_avx2 () from /lib64/libc.so.6
> (gdb)
> 
> Is there any workaround for this as an end user?

Unfortunately not (or at least not that I'm aware of).  This happens because GDB doesn't have support for reverse-debugging this instruction (and some others, FWIW).  If you want to use reverse debugging and your binary contains this instruction, you will not be able to.

Comment 14 ell1e 2020-03-02 16:58:25 UTC
I am seeing this even with -O0 though, so is there even a way to avoid this? The backtrace makes it look like the libc.so.6 system-wide binary is the culprit. If it is, can a gdb end user even realistically avoid running into this issue? It feels to me like gdb's reverse debugging as packaged is currently fundamentally incompatible with how Fedora's own base system is shipped. That seems like a problem if that is the case

Comment 15 Jan Kratochvil 2020-03-02 17:32:08 UTC
Created attachment 1667028 [details]
glibc nomulti.patch

(In reply to Ellie from comment #14)
> If it is, can a gdb end user even realistically avoid running into this issue?

I see in Comment 5 I already coded some workaround.

Besides that you can build your own glibc without the multi-arch optimization and LD_PRELOAD it.  You also need LD_BIND_NOW as ld.so also has some multiarch optimization of its own.

$ echo -e '#include <string.h>\nint main(int argc,char **argv) {\nsize_t l=strlen(argv[0]);\nreturn l;}' >strlen.c;gcc -Wall -g -o strlen strlen.c;gdb -q ./strlen -ex start -ex record -ex n
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffd028) at strlen.c:3
3	size_t l=strlen(argv[0]);
Process record does not support instruction 0xfae64 at address 0x7ffff7fe86bc.
Process record: failed to record execution log.
Program stopped.
_dl_runtime_resolve_xsave () at ../sysdeps/x86_64/dl-trampoline.h:117
(gdb) _

vs.

$ echo -e '#include <string.h>\nint main(int argc,char **argv) {\nsize_t l=strlen(argv[0]);\nreturn l;}' >strlen.c;gcc -Wall -g -o strlen strlen.c;gdb -q ./strlen -ex 'set env LD_BIND_NOW=1' -ex start -ex record -ex n
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffd008) at strlen.c:3
3	size_t l=strlen(argv[0]);
Process record does not support instruction 0xc5 at address 0x7ffff7f23849.
Process record: failed to record execution log.
Program stopped.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:57
(gdb) _

vs.

$ echo -e '#include <string.h>\nint main(int argc,char **argv) {\nsize_t l=strlen(argv[0]);\nreturn l;}' >strlen.c;gcc -Wall -g -o strlen strlen.c;gdb -q ./strlen -ex 'set env LD_BIND_NOW=1' -ex 'set env LD_LIBRARY_PATH=/home/jkratoch/redhat/fedora/glibc/f31/BUILDROOT/glibc-2.30-10nomulti.fc31.x86_64/lib64' -ex start -ex record -ex n
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffcfc8) at strlen.c:3
3	size_t l=strlen(argv[0]);
4	return l;}
(gdb) _

Comment 16 ell1e 2020-03-02 18:19:55 UTC
Well I get that some experts can work around this, but this doesn't seem super achievable for regular users like me.

The libstring.so workaround looks nice and quick, but you're losing me with the other variants and I think most others will also be lost. As a result, there's a practical accessibility problem for this feature right now which is a bit of a shame. I often just do printf debugging instead of gdb, and this would be one of THE features to get me to use it way more if it worked

Comment 17 ell1e 2020-03-02 18:28:18 UTC
An idea: would it be possible prepackage a separate libc compatible with this maybe? libc-unoptimized.so.6, or such. The dnf package could then be described somewhere (and that mention ideally linked from the gdb error itself) for quick install & use

Comment 18 Jan Kratochvil 2020-03-02 19:32:26 UTC
TBH fixing this bug is not a big deal to consider some packaging of workarounds.  It is just so boring to follow the instruction encodings tables/documentation nobody wants to do that.

Comment 19 David Smith 2020-05-07 19:08:13 UTC
Moving to DTS.

Comment 21 David Smith 2020-05-07 19:12:34 UTC
Correctly moving this bug to RHEL8.

Comment 24 David Smith 2020-11-03 18:51:05 UTC
Closing this bug. Perhaps when upstream addresses it, we can reopen this RHEL bug.