From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 416953858D1E; Fri, 30 Dec 2022 23:43:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 416953858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672443838; bh=vW/NunazjZHMTNGAsb7dVExO6wB0oPD9BMpw4MFEVq8=; h=From:To:Subject:Date:From; b=UP9XoO58G70LUQdi6Eq/juyaXF4TQgM5AZyL/d504jZDREcHUNxsIYBwOGeauet5v dpnqy6gz+7SaAT8gLtKxGOxZlqeeUTBgdcbq52qLN3fuVOBH69yZAZuN+GwVzGm5Td 3BrzW2aWuX4bpHiN+Me33YWdh2mSYMxnjtXnH8Fw= From: "udaysha01 at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug symtab/29950] New: debugging stabs+ binary hits assertion`idx >= 0 && idx < num_fields ()' Date: Fri, 30 Dec 2022 23:43:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: symtab X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: udaysha01 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29950 Bug ID: 29950 Summary: debugging stabs+ binary hits assertion`idx >=3D 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 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 >=3D 0 && idx < num_f= ields ()' 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 debuggi= ng info for f, which objdump tells me is this f:F(0,1)=3D@s8;-16; the semicolon at the end seems to confuse gdb. the following bit of code fr= om gdb/stabsread.c indicates that this semicolon should be followed by some st= uff specific to "Sun acc" (I assume this is some other compiler?) but that's clearly not the case here - we have *p =3D=3D ';' in a file produced by gcc= . should we have a condition stricter than *p =3D=3D ';' for doing the Sun acc-speci= fic stuff? is anyone familiar enough with Sun acc to give input on what the condition should be? /* fall into process_prototype_types. */=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 // note: *p is ';' here process_prototype_types:=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 /* Sun acc puts declared types of arguments here. */=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 if (*p =3D=3D ';')=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 { ... 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 m= ight be worth fixing for similar use cases. --=20 You are receiving this mail because: You are on the CC list for the bug.=