From patchwork Mon Oct 2 12:50:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 76944 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F31B638555AB for ; Mon, 2 Oct 2023 12:51:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F31B638555AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696251080; bh=hXwpuNH0NpVQb/jVaC0D95JRieydW1t568sXd4f5o34=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ESwMyIDRgCHASfahHmo0akaqKFrV0Tq4OOXIVQHaa9qqBiMZXmXXlEzE4Il+5Tiic cm1zdY64ePoQtok2WiEsFjaqYuxahGtePPgumTkqr0dP5fW4upJSAmJm8rzYcHzDbI +44Jzo2A50IFPxwNqyoboyZGrfPRAs4OesH0QRvA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 811E83858024 for ; Mon, 2 Oct 2023 12:50:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 811E83858024 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B07972185E for ; Mon, 2 Oct 2023 12:50:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A04C113434 for ; Mon, 2 Oct 2023 12:50:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AJomJqa8GmVZMgAAMHmgww (envelope-from ) for ; Mon, 02 Oct 2023 12:50:46 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 03/13] [gdb/symtab] Handle nullptr parent in parent_map::set_parent Date: Mon, 2 Oct 2023 14:50:41 +0200 Message-Id: <20231002125051.29911-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231002125051.29911-1-tdevries@suse.de> References: <20231002125051.29911-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Set_parent uses m_die_range_map.set_empty, which doesn't allow parent_entry == nullptr. So it may be necessary to guard calls to set_parent with "if (parent_entry != nullptr)". Fix this by handling the parent_entry == nullptr case. Tested on x86_64-linux. --- gdb/dwarf2/cooked-index.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 9900dbb84a7..b51128d1f58 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -253,7 +253,10 @@ class parent_map void set_parent (CORE_ADDR start, CORE_ADDR end, const cooked_index_entry *parent_entry) { - m_parent_map.set_empty (start, end, (void *)parent_entry); + /* Calling set_empty with nullptr is currently not allowed. Note that we + still check the desired effect. */ + if (parent_entry != nullptr) + m_parent_map.set_empty (start, end, (void *)parent_entry); /* Assert that set_parent has the desired effect. This is not trivial due to how set_empty works. If the range already has been set before, it