From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kKYrFAm412rAojsAWB0awg (envelope-from ) for ; Tue, 20 Oct 2026 14:50:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1792522249; bh=tyMPSv7jTEkNPPpUPNf+IrsD1dqNjnbaYfUXbaF4uVo=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DrQKzJTT9LQ4RD9KaiYa6C8UO/ZEm75yZa0PX6uyfr4q7N5U5FHnsLKNrffid79/a jALw2X9XYp0DxWFYJEnyfvvFsOETOtWKBD7nNP7mKmkADBdaRag6u2miQpL4H0qwRC YLSSPFdVEirT9bA9DjheEDUaX65VpfWDZZIUk0DQ= Received: by simark.ca (Postfix, from userid 112) id 3ED391E051; Tue, 20 Oct 2026 14:50:49 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=IYFNIhdC; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D5DCF1E04D for ; Tue, 20 Oct 2026 14:50:44 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 067ED4A9F1DC for ; Tue, 20 Oct 2026 18:50:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 067ED4A9F1DC Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=IYFNIhdC Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 60F834AA299D for ; Tue, 20 Oct 2026 18:50:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60F834AA299D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 60F834AA299D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792522220; cv=none; b=XsO6UWRAm0BWBPqjuScUC0+lgZ2mqqBcFnSc1dhdcrm78c28iA+c3s7Vb90WG7n2x8fbBK5CSSlrjKkgOaj/Ye43P5fyNntbNEcmaB9ldwdWuQNtrpEW87qKiDfsMT+hOL4tIZblJb9J2hF5A0elb0Rt8Yxso06LH+FBiAWhuEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792522220; c=relaxed/simple; bh=tyMPSv7jTEkNPPpUPNf+IrsD1dqNjnbaYfUXbaF4uVo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=B0NnFP6T9baroCGgxszs/NNLLMEuuSe6ckJ67lC7yDQoapYk/ntfokR/bkDweDWcfHSV3TnC2gEWerJw0Av1is0hoRYTuiC6I/MPpqAqCTPrXRyDKiTCXhf0UHMq+dg4jiL60/mzaiYBIsy1dEn3hyJ6D/dIWRvIDMKpygTK06g= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=IYFNIhdC DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60F834AA299D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1792522220; bh=tyMPSv7jTEkNPPpUPNf+IrsD1dqNjnbaYfUXbaF4uVo=; h=Date:Subject:To:References:From:In-Reply-To:From; b=IYFNIhdCEQ9PeG2NhDRXrG2Y9XF9tl0JE2a1rn7r3NprNBHkMppMf5OrSXmZ1EmxA Shky5vUwICnGzO0HqWGQw0CjEv7Wq7URA6FAID17J1cM9a4xk7LUGFDdXdi3GrxPwD 6q2N0XacrrF8FBXmxFV5Tu8U5kNf+S+QdX0cGIeo= Received: by simark.ca (Postfix) id 90E251E04D; Tue, 20 Oct 2026 14:50:19 -0400 (EDT) Message-ID: Date: Tue, 20 Oct 2026 14:50:18 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/6] gdb: handle incorrect CU size in .gdb_index To: Andrew Burgess , gdb-patches@sourceware.org References: <88ff5bde0bbf7a68181ac199bc7facba4fa55432.1792356284.git.aburgess@redhat.com> Content-Language: fr From: Simon Marchi In-Reply-To: <88ff5bde0bbf7a68181ac199bc7facba4fa55432.1792356284.git.aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 10/18/26 4:50 PM, Andrew Burgess wrote: > The CU list within the .gdb_index contains the offset of a CU and the > length of the CU. > > The length field is not needed when parsing the .gdb_index, it is > currently only used within GDB to pre-fill the length field of the > dwarf2_per_cu object. This pre-filled length is then validated in > dwarf2_per_cu::set_length when the real CU header is read from the > .debug_info. > > Unfortunately, this validation is currently done using a gdb_assert, > which is the wrong approach. Both the .gdb_index and the CU header > are untrusted external input. Either of them (or both of them) might > be wrong, and though they should have the same value, this is not > guaranteed. > > I cannot just replace the gdb_assert in dwarf2_per_cu::set_length with > a call to complaint, there are other paths where the length is > pre-filled from the actual CU header, in this case there should be no > possibility of a mismatch, and so gdb_assert is the correct approach. > > I could add a new member variable to dwarf2_per_cu that tracks if the > pre-filled length came from the real CU header or from the .gdb_index, > then we could switch on this to either call gdb_assert or complaint. > > But this seemed excessive when complaints are usually turned off by > default. > > Instead, I propose we just ignore the CU length from the .gdb_index, > and pass 0 instead when initially creating the dwarf2_per_cu object. > A length of 0 indicates that the CU length is unknown. When GDB reads > the actual CU header it will then set the length at this point. > > The CU length in the .gdb_index is no longer being used, but I am not > proposing that we change the .gdb_index format, though we could in > theory bump the index version number and remove the CU length, saving > a little space. However, changing the index format means more work > for downstream tools that read or write .gdb_index sections, so > avoiding that churn seems best to me. I think this is ok, dwarf2_find_containing_unit (one of the only things that uses a unit's length) is ready for this. Simon