From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12128 invoked by alias); 26 Mar 2009 22:35:21 -0000 Received: (qmail 12106 invoked by uid 22791); 26 Mar 2009 22:35:19 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Mar 2009 22:35:10 +0000 Received: (qmail 23698 invoked from network); 26 Mar 2009 22:35:08 -0000 Received: from unknown (HELO orlando) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 26 Mar 2009 22:35:08 -0000 From: Pedro Alves To: gdb@sourceware.org Subject: Re: when can find_thread_pid (inferior_ptid) return NULL? Date: Thu, 26 Mar 2009 22:35:00 -0000 User-Agent: KMail/1.9.10 Cc: Doug Evans References: <20090326213642.B9E771C74E3@localhost> In-Reply-To: <20090326213642.B9E771C74E3@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903262235.10443.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00170.txt.bz2 On Thursday 26 March 2009 21:36:42, Doug Evans wrote: > Hi. Some places in gdb assert that find_thread_pid (inferior_ptid) > is never NULL. > make_cleanup_restore_current_thread: > > tp = find_thread_pid (inferior_ptid); > if (tp) > tp->refcount++; I think that in this particular case, it will always be true. > > Since delete_thread_1 has this: > > /* If this is the current thread, or there's code out there that > relies on it existing (refcount > 0) we can't delete yet. Mark > it as exited, and notify it. */ > if (tp->refcount > 0 > || ptid_equal (tp->ptid, inferior_ptid)) > { > > I would expect that one can always assert > find_thread_pid (inferior_ptid) != NULL. > > Is that true? > Or are there situations where it's not true? When inferior_ptid is null_ptid. You'll also not find the old ptid if running the cleanup after something clears the thread list, e.g., after killing or poping the target. -- Pedro Alves