public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed
@ 2023-09-28 10:48 vries at gcc dot gnu.org
  2023-09-28 10:49 ` [Bug exp/30911] " vries at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-28 10:48 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30911

            Bug ID: 30911
           Summary: [gdb/exp] Cannot call ifunc strstr with debuginfo
                    installed
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: exp
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

[ This report is based on fedora patch gdb-glibc-strstr-workaround.patch (see
also PR glibc/14166). ]

Consider a hello world a.out with debug info.  Without glibc debug info
installed, I'm able to call strstr:
...
$ gdb -q a.out -ex start -ex "p strstr" -ex "ptype strstr"
Reading symbols from a.out...
Temporary breakpoint 1 at 0x40051b: file hello.c, line 6.
Starting program: /data/vries/gdb/a.out 

Temporary breakpoint 1, main () at hello.c:6
6         printf ("hello\n");
$1 = {<text gnu-indirect-function variable, no debug info>} 0x7ffff7e4f9ce
<strstr>
type = <unknown return type> ()
(gdb) p strstr ("haha", "ah")
'__strstr_sse2_unaligned' has unknown return type; cast the call to its
declared return type
(gdb) p (char *)strstr ("haha", "ah")
$2 = 0x7ffff7dab1b1 "aha"
(gdb) 
...

Now with glibc debug info installed:
...
$ gdb -q a.out -ex start -ex "p strstr" -ex "ptype strstr"
Reading symbols from a.out...
Temporary breakpoint 1 at 0x40051b: file hello.c, line 6.
Starting program: /data/vries/gdb/a.out 

Temporary breakpoint 1, main () at hello.c:6
6         printf ("hello\n");
$1 = {<text gnu-indirect-function variable, no debug info>} 0x7ffff7e4e9ce
<__libc_strstr_ifunc>
type = <unknown return type> ()
(gdb) p strstr ("haha", "ah")
$2 = void
(gdb) p (char *)strstr ("haha", "ah")
Invalid cast.
(gdb) 
...

This is with glibc 2.31 on openSUSE Leap 15.4.

With glibc 2.38 on openSUSE Tumbleweed this doesn't happen.

This seems to be caused by the fact that in the tumbleweed case we have an
unspecified_type return type:
...
 <1><11dd5e>: Abbrev Number: 1 (DW_TAG_subprogram)
    <11dd5f>   DW_AT_name        : __strstr_sse2_unaligned
    <11dd63>   DW_AT_external    : 1
    <11dd63>   DW_AT_type        : <0x11dd6e>
    <11dd64>   DW_AT_low_pc      : 0xb9c9e
    <11dd6c>   DW_AT_high_pc     : 1173
 <1><11dd6e>: Abbrev Number: 3 (DW_TAG_unspecified_type)
 <1><11dd6f>: Abbrev Number: 0
...
and in the failing case there's no type at all, which defaults to void:
...
<1><3e1e58>: Abbrev Number: 2 (DW_TAG_subprogram)
    <3e1e59>   DW_AT_name        : __strstr_sse2_unaligned
    <3e1e5d>   DW_AT_external    : 1
    <3e1e5e>   DW_AT_low_pc      : 0xbbd2e
    <3e1e66>   DW_AT_high_pc     : 0xbc1c3
...

This is basically PR gas/29517, fixed in 2.40 but present in 2.39.

What is curious though is that we do manage to find the correct type for the
revolver function:
...
(gdb) p __libc_strstr_ifunc
$3 = {char *(*(void))(const char *, const char *)} 0x7ffff7e4e9ce
<__libc_strstr_ifunc>
...
but we don't use it.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-10-16 14:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
2023-09-28 10:49 ` [Bug exp/30911] " vries at gcc dot gnu.org
2023-09-28 10:50 ` sam at gentoo dot org
2023-09-28 11:24 ` vries at gcc dot gnu.org
2023-09-28 11:54 ` vries at gcc dot gnu.org
2023-09-28 13:09 ` [Bug symtab/30911] " vries at gcc dot gnu.org
2023-09-28 16:08 ` vries at gcc dot gnu.org
2023-09-30  8:37 ` [Bug symtab/30911] [gdb/symtab] " vries at gcc dot gnu.org
2023-10-16 14:32 ` cvs-commit at gcc dot gnu.org
2023-10-16 14:33 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).