From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92580 invoked by alias); 19 Nov 2019 00:12:22 -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 92563 invoked by uid 89); 19 Nov 2019 00:12:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-13.9 required=5.0 tests=AWL,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; Tue, 19 Nov 2019 00:12:12 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 9CD8620250; Mon, 18 Nov 2019 19:12:10 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id BA9812012A; Mon, 18 Nov 2019 19:12:00 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 75D922816F; Mon, 18 Nov 2019 19:12:00 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Tue, 19 Nov 2019 00:12:00 -0000 From: "Sergio Durigan Junior (Code Review)" To: Sergio Durigan Junior , gdb-patches@sourceware.org Cc: Pedro Alves , Simon Marchi Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review v2] Fix crash with core + TUI + run X-Gerrit-Change-Id: I39e2f8b538c580c8ea5bf1d657ee877e47746c8f X-Gerrit-Change-Number: 483 X-Gerrit-ChangeURL: X-Gerrit-Commit: 2ba4b368991cf0ca1f8e7189986aefe6c03cea81 In-Reply-To: References: X-Gerrit-Comment-Date: Mon, 18 Nov 2019 19:11:59 -0500 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Content-Type: text/plain; charset=UTF-8 Message-Id: <20191119001200.75D922816F@gnutoolchain-gerrit.osci.io> X-SW-Source: 2019-11/txt/msg00563.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 2: (2 comments) Thanks for the review. I updated the commit message and will push the patch. | --- /dev/null | +++ /COMMIT_MSG | @@ -1,0 +74,20 @@ have a target already, and tries to close it (from target.c): | + target_close (prev); // <-- here | + } | + ... | + | +When the current target ('core_target') is being closed, it checks for | +possible observers registered with it and calls them. TUI is one of | +those observers, it gets called, tries to update the status line, and | +GDB crashes. | + | +The real problem is that we are calling 'target_close' too soon, | +before we actually have the new target on top of the stack. PS2, Line 84: Done. | +Interestingly, this scenario is covered in 'target_stack::unpush', but | +for some reason we are not calling it here. The fix, therefore, is to | +call 'unpush' if there's a target on the stack. | + | +This patch has been tested on the Buildbot and no regressions have | +been found. I'm also submitting a testcase for it. | + | +gdb/ChangeLog: | +2019-11-08 Sergio Durigan Junior | --- 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: Done | if (m_top < stratum) | m_top = stratum; | } | | /* See target.h. */ | | void | push_target (struct target_ops *t) | { -- Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: I39e2f8b538c580c8ea5bf1d657ee877e47746c8f Gerrit-Change-Number: 483 Gerrit-PatchSet: 2 Gerrit-Owner: Sergio Durigan Junior Gerrit-Reviewer: Pedro Alves Gerrit-Reviewer: Sergio Durigan Junior Gerrit-CC: Simon Marchi Gerrit-Comment-Date: Tue, 19 Nov 2019 00:11:59 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: Pedro Alves Comment-In-Reply-To: Sergio Durigan Junior Gerrit-MessageType: comment