From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A921D385C426; Fri, 8 May 2020 12:40:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A921D385C426 From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/25950] New: [debug-names] Handle no "Hash Lookup Table" Date: Fri, 08 May 2020 12:40:43 +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: vries at gcc dot gnu.org X-Bugzilla-Status: NEW 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 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 May 2020 12:40:43 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D25950 Bug ID: 25950 Summary: [debug-names] Handle no "Hash Lookup Table" Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: symtab Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- The .debug_names section defines a "Hash Lookup Table": ... The hash lookup table is actually two separate arrays: - an array of buckets, followed immediately by - an array of hashes. The number of entries in the buckets array is given by bucket_count, and the number of entries in the hashes array is given by name_count. ... According to the standard, the "Hash Lookup Table" is an optional part of .debug_names. Presumably, a .debug_names section without a "Hash Lookup Table" is characterized by bucket_count =3D=3D 0, but not by name_count =3D=3D 0, sin= ce name_count means an empty index. Gdb however has this code: ... /* Hash Lookup Table */ map.bucket_table_reordered =3D reinterpret_cast (addr); addr +=3D map.bucket_count * 4; map.hash_table_reordered =3D reinterpret_cast (addr); addr +=3D map.name_count * 4; ... So, it expects to read the hash_table, even if bucket_count is 0. This patch fixes that: ... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index eba5ee7897..80cbcc6c78 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4952,8 +4952,13 @@ read_debug_names_from_section (struct objfile *objfi= le, /* Hash Lookup Table */ map.bucket_table_reordered =3D reinterpret_cast (addr); addr +=3D map.bucket_count * 4; - map.hash_table_reordered =3D reinterpret_cast (addr); - addr +=3D map.name_count * 4; + if (map.bucket_count > 0) + { + map.hash_table_reordered =3D reinterpret_cast (add= r); + addr +=3D map.name_count * 4; + } + else + map.hash_table_reordered =3D nullptr; /* Name Table */ map.name_table_string_offs_reordered =3D addr; ... but then we run into a SIGFPE in dw2_debug_names_iterator::find_vec_in_debug_names here: ... uint32_t namei =3D extract_unsigned_integer (reinterpret_cast (map.bucket_table_reordered + (full_hash % map.bucket_count)), 4, map.dwarf5_byte_order); ... because map.bucket_count =3D=3D 0, so we're dividing by zero. --=20 You are receiving this mail because: You are on the CC list for the bug.=