From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30032 invoked by alias); 27 Mar 2009 00:54:07 -0000 Received: (qmail 30024 invoked by uid 22791); 27 Mar 2009 00:54:06 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Mar 2009 00:53:59 +0000 Received: from wpaz1.hot.corp.google.com (wpaz1.hot.corp.google.com [172.24.198.65]) by smtp-out.google.com with ESMTP id n2R0rt5f020696 for ; Fri, 27 Mar 2009 00:53:55 GMT Received: from yw-out-1718.google.com (ywk9.prod.google.com [10.192.11.9]) by wpaz1.hot.corp.google.com with ESMTP id n2R0rYo9010318 for ; Thu, 26 Mar 2009 17:53:54 -0700 Received: by yw-out-1718.google.com with SMTP id 9so493631ywk.82 for ; Thu, 26 Mar 2009 17:53:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.90.53.5 with SMTP id b5mr862269aga.56.1238115233674; Thu, 26 Mar 2009 17:53:53 -0700 (PDT) In-Reply-To: <200903262235.10443.pedro@codesourcery.com> References: <20090326213642.B9E771C74E3@localhost> <200903262235.10443.pedro@codesourcery.com> Date: Fri, 27 Mar 2009 00:54:00 -0000 Message-ID: Subject: Re: when can find_thread_pid (inferior_ptid) return NULL? From: Doug Evans To: Pedro Alves Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-System-Of-Record: true 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/msg00172.txt.bz2 On Thu, Mar 26, 2009 at 3:35 PM, Pedro Alves wrote: > 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. Ya, I found that out shortly after ^c^c. What a surprise. :-)