From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6302E385842E; Wed, 15 Mar 2023 15:05:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6302E385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678892728; bh=DfBMjAlc5VHEOLclk9QfP3eOmH8IpcB0ZsoHeOIF5Ho=; h=From:To:Subject:Date:From; b=aOirD2GFe4/zrJQst9pZMNNnm7b+dqH/b8CvLX0cmyJosjjCtYDT268zgcCbgtev9 k0ggWf/bqVJsIHbrOrwMKWL/gYeY5zgRk7wmjE9TJCnFSkDJdYymOiJwp0Pvz4o1mB yj2ATjHW4i3uBgdRmdy76sTITFruuPl2hDvl0TQA= From: "blue.swallow.71 at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/30236] New: gdb crashes inspecting value of enum with more than 2^15 enumerators Date: Wed, 15 Mar 2023 15:05:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 12.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: blue.swallow.71 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=3D30236 Bug ID: 30236 Summary: gdb crashes inspecting value of enum with more than 2^15 enumerators Product: gdb Version: 12.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: blue.swallow.71 at gmail dot com Target Milestone: --- Tested with gdb 12.1 and compiled with g++ 11.3.0 Description: When debugging a program and trying to inspect (print) a value of an enum, = gdb will crash if said enum has more than 2^15 (32768) elements. Steps to reproduce: 1) create foo.h and define an enum with more than 32768 elements. =3D=3D=3Dfoo.h=3D=3D=3D enum Foo { value1, value2, // more values value32769 }; =3D=3D=3Dfoo.h=3D=3D=3D 2) create main.cpp and use any value from Foo enum =3D=3D=3Dmain.cpp #include "foo.h" int main() { Foo foo_var =3D value4; return 0; } =3D=3D=3Dmain.cpp=3D=3D=3D 3) compile main.cpp (e.g. g++ -g -O0 -o test main.cpp) 4) run gdb (e.g. gdb test) 5) setup a breakpoint at return 0; and run 6) inspect the value of foo_var or any of the elements of Foo (e.g. "print foo_var" or "print (int)value12" 7) gdb will crash with the following message: /build/gdb-ZgDh0V/gdb-12.1/gdb/gdbtypes.h:1064: internal-error: field: Assertion `idx >=3D 0 && idx < num_fields ()' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. ----- Backtrace ----- 0x560dd53b8077 ??? 0x560dd571ca64 ??? 0x560dd571cca0 ??? 0x560dd586c0e4 ??? 0x560dd572be35 ??? 0x560dd572b563 ??? 0x560dd53de2ed ??? 0x560dd572b6e5 ??? 0x560dd55d7aa4 ??? 0x560dd55d7d32 ??? 0x560dd53ed654 ??? 0x560dd56e3394 ??? 0x560dd54bb9a4 ??? 0x560dd54bbd43 ??? 0x560dd54bc4c6 ??? 0x7fbf92f05e0d ??? 0x560dd54baa95 ??? 0x560dd54bc374 ??? 0x560dd54ba68b ??? 0x560dd586c815 ??? 0x560dd586ccaa ??? 0x560dd557836c ??? 0x560dd557a054 ??? 0x560dd531015f ??? 0x7fbf91e80d8f __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 0x7fbf91e80e3f __libc_start_main_impl ../csu/libc-start.c:392 0x560dd5315bf4 ??? 0xffffffffffffffff ??? --------------------- /build/gdb-ZgDh0V/gdb-12.1/gdb/gdbtypes.h:1064: internal-error: field: Assertion `idx >=3D 0 && idx < num_fields ()' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) y This is a bug, please report it. For instructions, see: . /build/gdb-ZgDh0V/gdb-12.1/gdb/gdbtypes.h:1064: internal-error: field: Assertion `idx >=3D 0 && idx < num_fields ()' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) y Aborted (core dumped) --=20 You are receiving this mail because: You are on the CC list for the bug.=