[Bug gdb/34561] New: Problem reading OS generated corefiles on systems with Intel AMX support

"christina.joos at intel dot com via Gdb-prs" <[email protected]>
Newsgroups gmane.comp.gdb.bugs.discuss
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34561

            Bug ID: 34561
           Summary: Problem reading OS generated corefiles on systems with
                    Intel AMX support
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: christina.joos at intel dot com
  Target Milestone: ---

On Systems with Intel AMX support the xsave size is 11008. This xsave size is
not
handled by gdb/i387-tdep.c:i387_guess_xsave_layout and is causing problems for
OS
generated corefiles.

Consider the following simple test program to generate a corefile:
~~~
$ cat main.c
int main ()
{
  int *pointer = 0;
  *pointer = 3;

  return 0;
}
~~~

Steps to reproduce:
~~~
$ ./main
Segmentation fault (core dumped)
[...]
$ gdb-up
GNU gdb (GDB) 19.0.50.20260814-git
Copyright (C) 2026 Free Software Foundation, Inc.
[...]
(gdb) core core_main_SEGV
[New LWP 2162880 (id 1)]
[...]
Core was generated by `./main'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000593156bd713d in main () at main.c:4
4         *pointer = 3;
(gdb) p $ymm0
$1 = void
~~~

The issue is that we should be able to print the register $ymm0
(or any other register belonging to a feature higher than SSE). 
For a live debug session we can print it:
~~~
Reading symbols from main...
(gdb) start
Temporary breakpoint 1 at 0x1131: file main.c, line 3.
Starting program: /tmp/main
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, main () at main.c:3
3         int *pointer = 0;
(gdb) p $ymm0
$1 = {v16_bfloat16 = {0, 2.342e-38, 0 <repeats 14 times>}, v16_half = {0,
1.5199e-05, 0 <repeats 14 times>}, v8_float = {
    2.34180515e-38, 0, 0, 0, 0, 0, 0, 0}, v4_double = {8.256666972292243e-317,
0, 0, 0}, v32_int8 = {0, 0, -1,
    0 <repeats 29 times>}, v16_int16 = {0, 255, 0 <repeats 14 times>}, v8_int32
= {16711680, 0, 0, 0, 0, 0, 0, 0}, v4_int64 = {
    16711680, 0, 0, 0}, v2_int128 = {16711680, 0}}
[...]
~~~

This is should be reproducible on any CPU which supports AMX.
My machine has the following setup:
~~~
$ gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.4 LTS
~~~

Note that this is not reproducible for corefiles generated by the gcore
command, since gdb/i387-tdep.c:i387_fallback_xsave_layout will configure
the xsave_layout based on xcr0.  xcr0 is created based on the target
description from the corefile in i386_gdbarch_init.

i387_fallback_xsave_layout (i386_xcr0_from_tdesc (info.target_desc));

For OS generated corefiles the GDB target description is not available in
the corefile.

~~~
Reading symbols from main...
(gdb) start
Temporary breakpoint 1 at 0x1131: file main.c, line 3.
Starting program: /tmp/main
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, main () at main.c:3
3         int *pointer = 0;
(gdb) gcore core_main_gcore
⚠️ warning: Memory read failed for corefile section, 4096 bytes at
0xffffffffff600000.
Saved corefile core_main_gcore
[...]
(gdb) core core_main_gcore
[New LWP 2163444 (id 1)]
Reading symbols from /tmp/main...
⚠️ warning: Unexpected size of section `.reg-xstate/2163444' in core file.
[...]
Core was generated by `/tmp/main'.
Program terminated with signal SIGTRAP, Trace/breakpoint trap.
⚠️ warning: Unexpected size of section `.reg-xstate/2163444' in core file.
#0  main () at main.c:3
3         int *pointer = 0;
(gdb) p $ymm0
$1 = {v16_bfloat16 = {0, 2.342e-38, 0 <repeats 14 times>}, v16_half = {0,
1.5199e-05, 0 <repeats 14 times>}, v8_float = {
    2.34180515e-38, 0, 0, 0, 0, 0, 0, 0}, v4_double = {8.256666972292243e-317,
0, 0, 0}, v32_int8 = {0, 0, -1,
    0 <repeats 29 times>}, v16_int16 = {0, 255, 0 <repeats 14 times>}, v8_int32
= {16711680, 0, 0, 0, 0, 0, 0, 0}, v4_int64 = {
    16711680, 0, 0, 0}, v2_int128 = {16711680, 0}}
~~~

Even though the xsave_size is configured to 2696 in i387_fallback_xsave_layout
which is not correct for this system, it does not seem to be a problem
(or at least, I couldn't find a problem so far).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.