From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yIJQKBLfhl//JwAAWB0awg (envelope-from ) for ; Wed, 14 Oct 2020 07:20:50 -0400 Received: by simark.ca (Postfix, from userid 112) id A248C1EF6F; Wed, 14 Oct 2020 07:20:50 -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 1B14F1E58E for ; Wed, 14 Oct 2020 07:20:50 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B7BA93861862; Wed, 14 Oct 2020 11:20:49 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 013A43861812 for ; Wed, 14 Oct 2020 11:20:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 013A43861812 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 18FF3AC1D; Wed, 14 Oct 2020 11:20:47 +0000 (UTC) Date: Wed, 14 Oct 2020 13:20:45 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [committed][gdb] Fix segfault in solib_contains_address_p Message-ID: <20201014112044.GA1927@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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, Starting commit bb2a67773c "Use a std::vector in target_section_table" we run into: ... ERROR: GDB process no longer exists GDB process exited with wait status 22239 exp12 0 0 CHILDKILLED SIGABRT UNRESOLVED: gdb.base/exec-invalid-sysroot.exp: continue to exec catchpoint ... which reproduces as: ... Thread 1 "gdb" received signal SIGSEGV, Segmentation fault. solib_contains_address_p (address=4196111, solib=0x1dd9970) at /home/vries/gdb_versions/devel/src/gdb/solib.c:1120 1120 for (target_section &p : solib->sections->sections) (gdb) p solib->sections->sections Cannot access memory at address 0x0 ... Fix this by handling solib->sections == nullptr in solib_contains_address_p. Build and reg-tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb] Fix segfault in solib_contains_address_p gdb/ChangeLog: 2020-10-14 Tom de Vries PR gdb/26733 * solib.c (solib_contains_address_p): Handle 'solib->sections == nullptr'. --- gdb/solib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdb/solib.c b/gdb/solib.c index b4864429e9..28f6a4ecbf 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1113,6 +1113,9 @@ bool solib_contains_address_p (const struct so_list *const solib, CORE_ADDR address) { + if (solib->sections == nullptr) + return false; + for (target_section &p : *solib->sections) if (p.addr <= address && address < p.endaddr) return true;