public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/29950] New: debugging stabs+ binary hits assertion`idx >= 0 && idx < num_fields ()'
@ 2022-12-30 23:43 udaysha01 at gmail dot com
  2022-12-31  1:45 ` [Bug symtab/29950] " tromey at sourceware dot org
  2022-12-31 11:38 ` mark at klomp dot org
  0 siblings, 2 replies; 3+ messages in thread
From: udaysha01 at gmail dot com @ 2022-12-30 23:43 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 29950
           Summary: debugging stabs+ binary hits assertion`idx >= 0 && idx
                    < num_fields ()'
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: udaysha01 at gmail dot com
  Target Milestone: ---

Environment:
gdb version: GNU gdb (GDB) 14.0.50.20221230-git (built from hash
cb2a1d0aca416235aed885e4796eeb70fbcd3b95)
configured as: This GDB was configured as "x86_64-pc-linux-gnu".
uname -a: Linux uday-arch 6.1.1-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Wed, 21
Dec 2022 22:27:59 +0000 x86_64 GNU/Linux
gcc version: gcc (GCC) 12.2.0

How to trigger the bug:
1. create a file test.c with the following content:

#include <stdbool.h>

bool f() { return true; }

2. build it with gcc -gstabs+ test.c -c -o test.o

3. launch gdb test.o and run "info func"

4. resulting assertion and backtrace:

(gdb) info func
gdbtypes.h:985: internal-error: field: Assertion `idx >= 0 && idx < num_fields
()' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0x55bec1e6400b gdb_internal_backtrace_1
        /home/uday/programs/binutils-gdb/gdb/bt-utils.c:122
0x55bec1e6400b _Z22gdb_internal_backtracev
        /home/uday/programs/binutils-gdb/gdb/bt-utils.c:168
0x55bec226bc3c internal_vproblem
        /home/uday/programs/binutils-gdb/gdb/utils.c:396
0x55bec226beba _Z15internal_verrorPKciS0_P13__va_list_tag
        /home/uday/programs/binutils-gdb/gdb/utils.c:476
0x55bec23b9a9e _Z18internal_error_locPKciS0_z
        /home/uday/programs/binutils-gdb/gdbsupport/errors.cc:58
0x55bec21885a3 _ZNK4type5fieldEi
        /home/uday/programs/binutils-gdb/gdb/gdbtypes.h:985
0x55bec218ee19 _ZNK4type5fieldEi
        /home/uday/programs/binutils-gdb/gdb/symtab.h:1293
0x55bec218ee19 _Z13define_symbolmPKciiP7objfile
        /home/uday/programs/binutils-gdb/gdb/stabsread.c:1009
0x55bec1eeeead
_Z18process_one_symboliimPKcRKSt6vectorImSaImEEP7objfile8language
        /home/uday/programs/binutils-gdb/gdb/dbxread.c:2838
0x55bec1eef566 read_ofile_symtab
        /home/uday/programs/binutils-gdb/gdb/dbxread.c:2287
0x55bec1eef566 dbx_expand_psymtab
        /home/uday/programs/binutils-gdb/gdb/dbxread.c:2137
0x55bec1eee124 _ZN14legacy_psymtab14expand_psymtabEP7objfile
        /home/uday/programs/binutils-gdb/gdb/psympriv.h:430
...

I poked around a bit, it seems like gdb is trying to parse the stab debugging
info for f, which objdump tells me is this

f:F(0,1)=@s8;-16;

the semicolon at the end seems to confuse gdb. the following bit of code from
gdb/stabsread.c indicates that this semicolon should be followed by some stuff
specific to "Sun acc" (I assume this is some other compiler?) but that's
clearly not the case here - we have *p == ';' in a file produced by gcc. should
we have a condition stricter than *p == ';' for doing the Sun acc-specific
stuff? is anyone familiar enough with Sun acc to give input on what the
condition should be?

      /* fall into process_prototype_types.  */                                 

      // note: *p is ';' here

    process_prototype_types:                                                    
      /* Sun acc puts declared types of arguments here.  */                     
      if (*p == ';')                                                            
  {
...

BTW I know -gstabs+ is deprecated now and dwarves is preferred instead. I
initially hit the bug when debugging an ancient binary and think it still might
be worth fixing for similar use cases.

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

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

* [Bug symtab/29950] debugging stabs+ binary hits assertion`idx >= 0 && idx < num_fields ()'
  2022-12-30 23:43 [Bug symtab/29950] New: debugging stabs+ binary hits assertion`idx >= 0 && idx < num_fields ()' udaysha01 at gmail dot com
@ 2022-12-31  1:45 ` tromey at sourceware dot org
  2022-12-31 11:38 ` mark at klomp dot org
  1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2022-12-31  1:45 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
> BTW I know -gstabs+ is deprecated now and dwarves is preferred instead

I think GCC removed stabs support.
Anyway stabs in gdb are maintained on a "best effort" basis.
As far as I know, nobody really works in this area or supports
stabs at all.

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

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

* [Bug symtab/29950] debugging stabs+ binary hits assertion`idx >= 0 && idx < num_fields ()'
  2022-12-30 23:43 [Bug symtab/29950] New: debugging stabs+ binary hits assertion`idx >= 0 && idx < num_fields ()' udaysha01 at gmail dot com
  2022-12-31  1:45 ` [Bug symtab/29950] " tromey at sourceware dot org
@ 2022-12-31 11:38 ` mark at klomp dot org
  1 sibling, 0 replies; 3+ messages in thread
From: mark at klomp dot org @ 2022-12-31 11:38 UTC (permalink / raw)
  To: gdb-prs

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
(In reply to Tom Tromey from comment #1)
> I think GCC removed stabs support.

STABS support has been deprecated in gcc 12 and removed in (the soon to be
released) gcc 13:

https://gcc.gnu.org/gcc-12/changes.html
https://gcc.gnu.org/gcc-13/changes.html

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

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

end of thread, other threads:[~2022-12-31 11:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-30 23:43 [Bug symtab/29950] New: debugging stabs+ binary hits assertion`idx >= 0 && idx < num_fields ()' udaysha01 at gmail dot com
2022-12-31  1:45 ` [Bug symtab/29950] " tromey at sourceware dot org
2022-12-31 11:38 ` mark at klomp dot 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).