From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129000 invoked by alias); 8 Nov 2019 21:26:20 -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 128992 invoked by uid 89); 8 Nov 2019 21:26:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2019 21:26:18 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id F0918200EF; Fri, 8 Nov 2019 16:26:16 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 7B5D1200EF; Fri, 8 Nov 2019 16:26:15 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 62F1A2816F; Fri, 8 Nov 2019 16:26:15 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Fri, 08 Nov 2019 21:26:00 -0000 From: "Sergio Durigan Junior (Code Review)" To: Sergio Durigan Junior , gdb-patches@sourceware.org Cc: Pedro Alves Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review] Fix crash with core + TUI + run X-Gerrit-Change-Id: I39e2f8b538c580c8ea5bf1d657ee877e47746c8f X-Gerrit-Change-Number: 483 X-Gerrit-ChangeURL: X-Gerrit-Commit: 9ef2f42f9cbbd0fa45026c061f5bf978f2485e5e In-Reply-To: References: X-Gerrit-Comment-Date: Fri, 8 Nov 2019 16:26:14 -0500 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-76-gf8b6da0ab5 Content-Type: text/plain; charset=UTF-8 Message-Id: <20191108212615.62F1A2816F@gnutoolchain-gerrit.osci.io> X-SW-Source: 2019-11/txt/msg00243.txt.bz2 Sergio Durigan Junior has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/483 ...................................................................... Patch Set 1: (3 comments) On Tuesday, November 05 2019, Pedro Alves wrote: > --- /dev/null > +++ /COMMIT_MSG > @@ -1,0 +1,16 @@ > +Parent: e48f6033 (Move check for strerror_r to common.m4 where it belongs) > +Author: Sergio Durigan Junior > +AuthorDate: 2019-10-30 13:58:29 -0400 > +Commit: Sergio Durigan Junior > +CommitDate: 2019-11-01 11:53:06 -0400 > + > +Make sure we have a valid target on top when pushing a new target PS1, Line 7: Thanks for the review. I changed the subject as suggested. > + > +Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1765117 > + > +A segfault can happen in a specific scenario when using TUI + a > +corefile, as explained in the bug mentioned above. The problem > +happens when opening a corefile on GDB: > + > + $ gdb ./core program > + > --- gdb/target.c > +++ gdb/target.c > @@ -569,14 +566,18 @@ target_stack::push (target_ops *t) > - } > + prev = m_stack[stratum]; > > /* Now add the new one. */ > m_stack[stratum] = t; > > + /* And close the previous one, if it exists. */ > + if (prev != nullptr) > + target_close (prev); > + PS1, Line 574: >> /* Finally close the target. Note we do this after unchaining, so >> any target method calls from within the target_close >> implementation don't end up in T anymore. */ >> target_close (t); >> /* Unchain the target. */ >> m_stack[stratum] = NULL; >> >> if (m_top == stratum) >> m_top = t->beneath ()->stratum (); >> >> /* Finally close the target. Note we do this after unchaining, so >> any target method calls from within the target_close >> implementation don't end up in T anymore. */ >> target_close (t); Interesting. While hacking, I wasn't sure if I should call 'unpush' directly (even wrote about that in the commit message), but in the end decided to just reorder the call to 'target_close'. It's interesting that I read the comment on 'unpush' regarding calling 'target_close' after unchaining... Anyway, thanks for pointing this out. I updated the patch. > if (m_top < stratum) > m_top = stratum; > } > > /* See target.h. */ > > void > push_target (struct target_ops *t) > { > --- /dev/null > +++ gdb/testsuite/gdb.tui/segfault-corefile-run.exp > @@ -1,0 +1,10 @@ > +# Copyright 2019 Free Software Foundation, Inc. PS1, Line 1: Fair enough; renamed. Thanks. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: I39e2f8b538c580c8ea5bf1d657ee877e47746c8f Gerrit-Change-Number: 483 Gerrit-PatchSet: 1 Gerrit-Owner: Sergio Durigan Junior Gerrit-Reviewer: Pedro Alves Gerrit-Reviewer: Sergio Durigan Junior Gerrit-Comment-Date: Fri, 08 Nov 2019 21:26:14 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: Pedro Alves Gerrit-MessageType: comment