From patchwork Fri Jan 17 03:47:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 37415 Received: (qmail 107277 invoked by alias); 17 Jan 2020 03:47:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 107242 invoked by uid 89); 17 Jan 2020 03:47:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=tid-reuse.exp, UD:tid-reuse.exp, tidreuseexp 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; Fri, 17 Jan 2020 03:47:26 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id EB9E31E4A4; Thu, 16 Jan 2020 22:47:24 -0500 (EST) Subject: Re: [PATCH v2 18/24] Multi-target support To: Pedro Alves , gdb-patches@sourceware.org References: <20191017225026.30496-1-palves@redhat.com> <20191017225026.30496-19-palves@redhat.com> From: Simon Marchi Message-ID: Date: Thu, 16 Jan 2020 22:47:24 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20191017225026.30496-19-palves@redhat.com> On 2019-10-17 6:50 p.m., Pedro Alves wrote: > This commit adds multi-target support to GDB. What this means is that > with this commit, GDB can now be connected to different targets at the > same time. E.g., you can debug a live native process and a core dump > at the same time, connect to multiple gdbservers, etc. Hi Pedro, I think I found something odd happening starting with this commit. When the test gdb.threads/tid-reuse.exp runs, we are adding a thread_info to the inferior's thread list when a thread_info object with the same ptid is already present. I don't think this is ever supposed to happen, right? This can be observed by applying the following diff and running gdb.threads/tid-reuse.exp. Note that some distributions are starting to bump pid_max to a really large value, so make sure it's not that on your system. What I have found so far, by breaking at thread.c:274 and stepping into the "delete_thread" call, is that `inferior_ptid == ptid` is false (inferior_ptid is (0,0,0)). In delete_thread, we are actually not deleting the thread because ->deletable () returns false, because the refcount is 2. Before this patch, we would enter the `if (inferior_ptid == ptid)`. If it can help, here is the command line I'm using to debug this, which is mimicking the test: ./gdb -nx --data-directory=data-directory testsuite/outputs/gdb.threads/tid-reuse/tid-reuse -iex "set confirm off" -iex "set pagination off" -ex start -ex "set print thread-events off" -ex "b after_count" -ex c -ex "b do_nothing_thread_func" -ex c -ex d -ex "b after_reuse_time" -ex c Simon diff --git a/gdb/thread.c b/gdb/thread.c index 4959f938c7f3..8909e371e2ce 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -254,7 +254,10 @@ new_thread (struct inferior *inf, ptid_t ptid) struct thread_info *last; for (last = inf->thread_list; last->next != NULL; last = last->next) - ; + gdb_assert (ptid != last->ptid); + + gdb_assert (ptid != last->ptid); + last->next = tp; }