From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IA0ZDzekkV+FQAAAWB0awg (envelope-from ) for ; Thu, 22 Oct 2020 11:24:39 -0400 Received: by simark.ca (Postfix, from userid 112) id 39E3E1E89B; Thu, 22 Oct 2020 11:24:39 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A7F8E1E552 for ; Thu, 22 Oct 2020 11:24:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 33286386F427; Thu, 22 Oct 2020 15:24:37 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 4852E3861925 for ; Thu, 22 Oct 2020 15:24:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4852E3861925 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5B9C4AC48 for ; Thu, 22 Oct 2020 15:24:34 +0000 (UTC) Date: Thu, 22 Oct 2020 17:24:32 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [committed][gdb/symtab] Make find_block_in_blockvector more robust Message-ID: <20201022152431.GA13910@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, While working on PR25858 I noticed that the following trigger patch: ... @@ -2918,6 +2918,7 @@ find_pc_sect_compunit_symtab const struct blockvector *bv; bv = COMPUNIT_BLOCKVECTOR (cust); + (volatile int)blockvector_contains_pc (bv, pc); b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); if (BLOCK_START (b) <= pc ... triggers this assert, which checks that the returned block indeed contains pc: ... @@ -170,7 +170,10 @@ find_block_in_blockvector { b = BLOCKVECTOR_BLOCK (bl, bot); if (BLOCK_END (b) > pc) - return b; + { + gdb_assert (BLOCK_START (b) <= pc); + return b; + } bot--; } ... when running test-case gdb.ada/bp_c_mixed_case.exp. It's possible that the trigger patch breaks an undocumented invariant: I've tried a build and test run without the trigger patch and did not manage to trigger the assert. For robustness-sake, fix the assert by bailing out if 'BLOCK_START (b) <= pc' doesn't hold. Tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb/symtab] Make find_block_in_blockvector more robust gdb/ChangeLog: 2020-10-22 Tom de Vries * block.c (find_block_in_blockvector): Make sure the returned block contains pc. --- gdb/block.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdb/block.c b/gdb/block.c index 597d6d5d87..070d3f7769 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -166,6 +166,8 @@ find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc) while (bot >= STATIC_BLOCK) { b = BLOCKVECTOR_BLOCK (bl, bot); + if (!(BLOCK_START (b) <= pc)) + return NULL; if (BLOCK_END (b) > pc) return b; bot--;