From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D5B083858402; Sat, 11 Sep 2021 23:43:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5B083858402 From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug libdw/28294] dwarf_aggregate_size fails on some array types Date: Sat, 11 Sep 2021 23:43:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: libdw X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mark at klomp dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Sep 2021 23:43:14 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28294 --- Comment #2 from Mark Wielaard --- (In reply to Eli Boling from comment #0) > In dwarf_aggregate_size.c, the helper function array_size unconditionally > uses dwarf_formsdata to obtain the value of the DW_AT_upper_bound attribu= te > for array types. In many cases, this will return a negative value for C > arrays that have positive upper bounds, causing the function to return a > failure value, which propagates up through dwarf_aggregate_size. >=20 > This is an exemplary type (via readelf -w): > <1><90e>: Abbrev Number: 37 (DW_TAG_array_type) > <90f> DW_AT_type : <0x118> > <2><913>: Abbrev Number: 11 (DW_TAG_subrange_type) > <914> DW_AT_type : <0x2c> > <918> DW_AT_upper_bound : 249 >=20 > And the same type, via eu-readelf --debug-dump=3Dinfo: > [ 90e] array_type abbrev: 37 > type (ref4) [ 118] > [ 913] subrange_type abbrev: 11 > type (ref4) [ 2c] > upper_bound (data1) 249 >=20 > If dwarf_aggregate_size is called on this type, when it gets the upper_bo= und > attribute, it will get a value of -7, and fail. For other array sizes, t= his > will work. >=20 > Looking around a bit, the closest discussion I could find on the topic was > this one about signed vs unsigned interpretation of array bounds back in > 2005: > http://www.dwarfstd.org/ShowIssue.php?issue=3D020702.1 >=20 > I exchanged emails with Mark Wielaard on this, and he indicated that this > did appear to be a bug, but he wasn't sure yet where the correct fix would > be. Could you try the attached patch? I don't know if it works, it depends on the subrange_type at [2c]. If it doesn't work, could you post the full debug-dump or attach a test bin= ary? --=20 You are receiving this mail because: You are on the CC list for the bug.=