From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111353 invoked by alias); 26 Jan 2020 16:33:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 111338 invoked by uid 89); 26 Jan 2020 16:33:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=objfile_name X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.149.222) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Jan 2020 16:33:57 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 4491E4D26 for ; Sun, 26 Jan 2020 10:24:17 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id vkhtidc2WuRkOvkhtixWb9; Sun, 26 Jan 2020 10:24:17 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Vnm9W378jIQ0zddJsm9TNns2dSUnsDFIT8SPilnMUaU=; b=C6ozBAoUP1O28H5SkD4aLUQqLs uCacx3qAjVy73amlcJhBQvCq1hED3uO3lv3GLdUDEgtCwgXL8L936RetoDVDWL5FUCdbAcETBk2LD UUUt0OaPmUIcDLjn++Hw65oGn; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:57834 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1ivkht-003WMq-1V; Sun, 26 Jan 2020 09:24:17 -0700 From: Tom Tromey To: Tom Tromey Cc: Andrew Burgess , gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: Reinitialize objfile::section_offsets during objfile reload References: <20200125225555.16846-1-andrew.burgess@embecosm.com> <875zgy6vo5.fsf@tromey.com> Date: Sun, 26 Jan 2020 21:51:00 -0000 In-Reply-To: <875zgy6vo5.fsf@tromey.com> (Tom Tromey's message of "Sun, 26 Jan 2020 09:15:38 -0700") Message-ID: <871rrm6v9r.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2020-01/txt/msg00852.txt.bz2 Andrew> When building and testing with '-D_GLIBCXX_DEBUG=1' I noticed that the Andrew> test gdb.base/reload.exp was failing. This turns out to be because Andrew> the objfile::section_offsets vector is not reinitialilzed during the Andrew> objfile reload process, and in this particular test, GDB ends up Andrew> indexing outside the bounds of the vector. Tom> Thanks for catching this. I wonder if this is a regression due to commit 6a053cb1ff643cec3349d7f2f47ae5573f82d613 Author: Tom Tromey Date: Mon Jan 6 14:34:52 2020 -0700 Change section_offsets to a std::vector See appended. I think at the time I thought removing this code would simply preserve the offsets. But maybe we instead should std::move the offsets out of the objfile and then move them back in? This change would preserve the old status quo. Tom @@ -2479,9 +2468,6 @@ reread_symbols (void) new_modtime = new_statbuf.st_mtime; if (new_modtime != objfile->mtime) { - struct section_offsets *offsets; - int num_offsets; - printf_filtered (_("`%s' has changed; re-reading symbols.\n"), objfile_name (objfile)); @@ -2556,14 +2542,6 @@ reread_symbols (void) error (_("Can't read symbols from %s: %s."), objfile_name (objfile), bfd_errmsg (bfd_get_error ())); - /* Save the offsets, we will nuke them with the rest of the - objfile_obstack. */ - num_offsets = objfile->num_sections; - offsets = ((struct section_offsets *) - alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets))); - memcpy (offsets, objfile->section_offsets, - SIZEOF_N_SECTION_OFFSETS (num_offsets)); - objfile->reset_psymtabs (); /* NB: after this call to obstack_free, objfiles_changed @@ -2595,15 +2573,6 @@ reread_symbols (void) build_objfile_section_table (objfile); - /* We use the same section offsets as from last time. I'm not - sure whether that is always correct for shared libraries. */ - objfile->section_offsets = (struct section_offsets *) - obstack_alloc (&objfile->objfile_obstack, - SIZEOF_N_SECTION_OFFSETS (num_offsets)); - memcpy (objfile->section_offsets, offsets, - SIZEOF_N_SECTION_OFFSETS (num_offsets)); - objfile->num_sections = num_offsets; - /* What the hell is sym_new_init for, anyway? The concept of distinguishing between the main file and additional files in this way seems rather dubious. */