From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3848 invoked by alias); 29 Apr 2017 23:26:18 -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 3836 invoked by uid 89); 29 Apr 2017 23:26:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=happening X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 29 Apr 2017 23:26:15 +0000 Received: by simark.ca (Postfix, from userid 33) id 48D4D1E4C1; Sat, 29 Apr 2017 19:26:16 -0400 (EDT) To: Doug Gilmore Subject: Re: [PATCH] Fix PR 21337 v2: segfault when re-reading symbols with remote debugging. X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 29 Apr 2017 23:26:00 -0000 From: Simon Marchi Cc: Luis Machado , gdb-patches@sourceware.org In-Reply-To: References: <20511c76-c816-d31d-5144-749eac9fc470@imgtec.com> <3c5ce0a0-72e5-4460-5555-ad2214866260@imgtec.com> <5c494cc147f71dd8246572aa0b815c9f@polymtl.ca> <7e9595026acbfd2f1a7bff321fa255e1@polymtl.ca> <5b5cc0a61e434a3406cbb25c16b8a550@polymtl.ca> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.5 X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00819.txt.bz2 On 2017-04-29 13:12, Doug Gilmore wrote: > On 04/28/17 18:41, Simon Marchi wrote: >> On 2017-04-28 19:44, Doug Gilmore wrote: >>> Hi Simon, >>> >>> After thinking about it my comment and code placement wasn't >>> particularly good. Something along the line's of Luis's change >>> is better. >>> >>> Does Luis's comment address the question you have? >>> >>> If so, Luis: Should is it OK we incorporate your changes in the >>> patch? >>> >>> I attached a diff for the change. >>> >>> Thanks, >>> >>> Doug >> >> Hi Doug, >> >> The comment certainly helps, but in the commit log I'd like to see a >> more detailed list of events that leads to the crash. >> >> Now that I look into it again, I think I understand. The >> objfile_pspace_info::sections array/vector is a list of obj_section >> pointers (in C++ we'd probably use an std::vector). >> That list contains pointers to all the sections from all the >> objfiles sorted in order of increasing address. They point directly >> to the sections allocated by the objfile in their obstacks (and >> accessible through objfile::sections). So when the obstack is freed >> in reread_symbols, the sorted list contains stale pointers. Is that >> it? > Right. >> >> If that's what's happening, then I'm more convinced the fix is >> right. Is this behaviour caught by a test? If not, could you write >> one? >> ... > I'll need to take a look. Last time I tried I it was more difficult > to expose the problem on the native build of GDB. reread_symbols is called when using the run (run_command_1), attach (attach_post_wait which then calls setup_inferior) and load (load_command) commands. So maybe something like this would reproduce it? - compile test program - launch gdb with test program - touch test program - run Simon