From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wYgdNSDO82oPrwAAWB0awg (envelope-from ) for ; Tue, 10 Nov 2026 21:08:32 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=wc5JYOeN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CA113378002; Tue, 10 Nov 2026 21:08:32 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 1193F1E043 for ; Tue, 10 Nov 2026 21:08:31 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70CA74BA2E28 for ; Wed, 11 Nov 2026 02:08:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70CA74BA2E28 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=wc5JYOeN Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id E67B34BA2E26 for ; Wed, 11 Nov 2026 02:07:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E67B34BA2E26 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E67B34BA2E26 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794362821; cv=none; b=eG2KdmX2ShF8u76OkvU/yIUunHJ7+o8qTehCkPq5Y4+SrQ9ppK1Q10kEd3d/H9OQUgoWJ8/GW3RIXoyfEmaKNjJnFf+YlOcd73A/MULrt2jmsubiB9t7B/309udA5IBDPqhOE+7KhhP1fIjf3lOL8xEEcNFsIaLbzD6lZp205UM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794362821; c=relaxed/simple; bh=ppzyieGRpTrLdIkRKNrJtwoOvdhzq1KyYnr8JGU1Brw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=wjfPs6fNPB7wnh6h8Dpkc9eVZc34yC2nwUnXqFhvBOQCZYM44ne/zEFdE4g+wvzVx/a7ZPxz8+MJkYMgGmzC+qPmHGSuABrZ5VCRGuaA5q22SN8tQ8L6gYqKpKQIe/av/cuUhHVKJPYvOL3pdaLQYX0BRJjsHKUyae41fc7Dc24= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=wc5JYOeN reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E67B34BA2E26 Received: from eig-obgw-5001b.ext.cloudfilter.net ([10.0.29.181]) by cmsmtp with ESMTPS id QoHtxGzrUyb4YQxjmx6TH5; Wed, 11 Nov 2026 02:06:58 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QxjlxTWmHxmi7QxjmxwlIF; Wed, 11 Nov 2026 02:06:58 +0000 X-Authority-Analysis: v=2.4 cv=KuFN2XWN c=1 sm=1 tr=0 ts=6af3cdc2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=ItBw4LHWJt0A:10 a=siM0CxXcGMe7XPtFHMoA:9 a=QEXdDO2ut3YA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dzpBHoEscmxhTbsYUSMQbKvnnzhuyXc2eiwIaALviTo=; b=wc5JYOeNdq5IbssofoarSVB3Ip lHFsSE8wpLk65X78NyHBCNKwgqNKgba6hGtYtTE6aJxnQT9zO+TVyHl1RJ+ERxMgPT2/N930PKfGM UTncnGwVNRxPmlbUysm/6FYAQ; Received: from 97-122-110-129.hlrn.qwest.net ([97.122.110.129]:38316 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQxjl-00000000IPM-1UrO; Tue, 10 Nov 2026 19:06:57 -0700 From: Tom Tromey Date: Tue, 10 Nov 2026 19:06:55 -0700 Subject: [PATCH 1/5] Reject null pointers in program_space::set_exec_bfd MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261110-minor-assert-v1-1-bb33660ca557@tromey.com> References: <20261110-minor-assert-v1-0-bb33660ca557@tromey.com> In-Reply-To: <20261110-minor-assert-v1-0-bb33660ca557@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.110.129 X-Source-L: No X-Exim-ID: 1xQxjl-00000000IPM-1UrO X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-129.hlrn.qwest.net ([192.168.122.1]) [97.122.110.129]:38316 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfAb11gxnJCWKWqRIlRYteOAxpgbKwYIg1mFdK6p9B9NU6DNC+xcIhNNe5TYwxkUbw8IvcwhGsT/hqrEb7wZLh87Ri+UPkDyjUhNCepC8G7WEVnD5sqGQ 9AmIAk782TbTg4FI8h4kfY1+oNo9H44JhtgLUg3Nf0Fx2J21LXocfjm3I4UARSSTOlbzA8eqp2gVHT6Wiyn6ihAcwDZ4/TDLzPw= 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 The sole caller of set_exec_bfd ensures that the passed-in BFD cannot be nullptr. It seemed to me that the method itself should assert this as well, as clearing the exec BFD requires a bit of extra work -- see program_space::exec_close. This also changes set_exec_bfd to require the precondition that there is currently no exec BFD; again, if there was one, exec_close would need to be called. --- gdb/exec.c | 6 +++--- gdb/progspace.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index 806f9b0a67a..4f0a0ca23e3 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -465,13 +465,13 @@ exec_file_attach (const char *filename, int from_tty) FOPEN_RUB, scratch_chan); else temp = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan); - current_program_space->set_exec_bfd (std::move (temp)); - - if (!current_program_space->exec_bfd ()) + if (temp == nullptr) error (_("\"%ps\": could not open as an executable file: %s."), styled_string (file_name_style.style (), scratch_pathname), bfd_errmsg (bfd_get_error ())); + current_program_space->set_exec_bfd (std::move (temp)); + /* gdb_realpath_keepfile resolves symlinks on the local filesystem and so cannot be used for "target:" files. */ gdb_assert (current_program_space->exec_filename () == nullptr); diff --git a/gdb/progspace.h b/gdb/progspace.h index a5ef3deb337..d0d8466a8e5 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -312,6 +312,8 @@ struct program_space /* Set the exec BFD for this program space to ABFD. */ void set_exec_bfd (gdb_bfd_ref_ptr &&abfd) { + gdb_assert (ebfd == nullptr); + gdb_assert (abfd != nullptr); ebfd = std::move (abfd); } -- 2.49.0