From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AEDFB385701C; Mon, 23 May 2022 15:30:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEDFB385701C From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/29168] New: [gdb/UB] gdb/dwarf2/read.c:17545:20:runtime error: shift exponent 127 is too large for 64-bit type 'long unsigned int' Date: Mon, 23 May 2022 15:30:05 +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: Mon, 23 May 2022 15:30:05 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29168 Bug ID: 29168 Summary: [gdb/UB] gdb/dwarf2/read.c:17545:20:runtime error: shift exponent 127 is too large for 64-bit type 'long unsigned int' 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: --- I build gdb with -fsanitize=3Dundefined, and ran into: ... (gdb) break foo.adb:40^M ^[[1m/data/vries/gdb_versions/devel/src/gdb/dwarf2/read.c:17545:20:^[[1m^[[= 31m runtime error: ^[[1m^[[0m^[[1mshift exponent 127 is too large for 64-bit ty= pe 'long unsigned int'^[[1m^[[0m^M ERROR: GDB process no longer exists GDB process exited with wait status 26953 exp9 0 1 UNRESOLVED: gdb.ada/arrayptr.exp: scenario=3Dall: gdb_breakpoint: set break= point at foo.adb:40 (eof) ERROR: Couldn't run foo ... It's related to the negative_mask assignment here: ... /* Normally, the DWARF producers are expected to use a signed constant form (Eg. DW_FORM_sdata) to express negative bounds. But this is unfortunately not always the case, as witnessed with GCC, for instance, where the ambiguous DW_FORM_dataN form is used instead. To work around that ambiguity, we treat the bounds as signed, and thus sign-extend their values, when the base type is signed. */ negative_mask =3D -((ULONGEST) 1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1)); if (low.kind () =3D=3D PROP_CONST && !base_type->is_unsigned () && (low.const_val () & negative_mask)) low.set_const_val (low.const_val () | negative_mask); if (high.kind () =3D=3D PROP_CONST && !base_type->is_unsigned () && (high.const_val () & negative_mask)) high.set_const_val (high.const_val () | negative_mask); ... With base type of 16 bytes: ... (gdb) p *base_type $2 =3D {pointer_type =3D 0x0, reference_type =3D 0x0, rvalue_reference_type= =3D 0x0,=20 chain =3D 0x3bf43c0, align_log2 =3D 0, m_instance_flags =3D 0, length =3D= 16,=20 main_type =3D 0x3bf4400} bit_offset =3D 454}}, dyn_prop_list =3D 0x0} (gdb) p base_type.main_type.name $4 =3D 0x7ffff42399e5 "long_long_long_unsigned" ... we're shifting a 64-bit value by 127 (16 * 8 - 1). --=20 You are receiving this mail because: You are on the CC list for the bug.=