From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32386 invoked by alias); 21 Sep 2011 17:39:51 -0000 Received: (qmail 32257 invoked by uid 22791); 21 Sep 2011 17:39:49 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Sep 2011 17:39:33 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=EU1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1R6Qlg-0005jq-DS from pedro_alves@mentor.com ; Wed, 21 Sep 2011 10:39:32 -0700 Received: from scottsdale.localnet ([172.16.63.104]) by EU1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 21 Sep 2011 18:39:30 +0100 From: Pedro Alves To: "Burkhardt, Glenn" Subject: Re: fail to attach to process on Solaris Date: Wed, 21 Sep 2011 17:39:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-11-generic; KDE/4.7.0; x86_64; ; ) Cc: gdb@sourceware.org References: <201109211746.23961.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201109211839.28701.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: 2011-09/txt/msg00087.txt.bz2 On Wednesday 21 September 2011 18:15:48, Burkhardt, Glenn wrote: > > It's libthread_db.so that maps a thread to a LWP id, so we > > may be missing some state checks and getting back a stale id. > > Try the "maint info sol-threads" command (I never noticed > > this command before), and let's see what state does > > libthread_db.so think the thread is in. I see that > > linux-thread-db.c (the glibc/linux fork of this code) has > > extra checks for ignoring threads in some states that the > > Solaris code doesn't have. > So, this time the first thread to fail is #68, and the maint command > shows the thread as having a 'zombie' LWP: > > - Sleep func: 0x6ccfa4 > user thread #67, lwp 67, (active) startfunc: bootStrap > user thread #69, lwp 69, (asleep) startfunc: bootStrap > - Sleep func: 0x6ccfa4 > user thread #2, lwp 2, (zombie) startfunc: bootStrap > user thread #61, lwp 61, (zombie) startfunc: bootStrap > user thread #64, lwp 64, (zombie) startfunc: bootStrap > user thread #65, lwp 65, (zombie) startfunc: bootStrap > user thread #70, lwp 70, (zombie) startfunc: bootStrap > user thread #66, lwp 66, (zombie) startfunc: bootStrap > user thread #68, lwp 68, (zombie) startfunc: bootStrap > (gdb) c > Continuing. > procfs: couldn't find pid 16946 (kernel thread 68) in procinfo list. > (gdb) det > Detaching from program: > /home/glenn.burkhardt/targets/sol/ata0a/rms/rms.sparc, process 16946 > > > A complete log of the session is attached. It got trimmed where it began to be interesting. :-( Okay, the linux code ignores zombie threads, like in the patch below. Does that help? There's a couple more places where it ignores zombie threads, that we may need to bring over as well. Look for TD_THR_ZOMBIE in linux-thread-db.c. -- Pedro Alves --- gdb/sol-thread.c | 3 +++ 1 file changed, 3 insertions(+) Index: src/gdb/sol-thread.c =================================================================== --- src.orig/gdb/sol-thread.c 2011-03-01 16:00:06.000000000 +0000 +++ src/gdb/sol-thread.c 2011-09-21 18:34:30.029928904 +0100 @@ -1177,6 +1177,9 @@ sol_find_new_threads_callback (const td_ if (retval != TD_OK) return -1; + if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) + return 0; /* A zombie -- ignore. */ + ptid = BUILD_THREAD (ti.ti_tid, PIDGET (inferior_ptid)); if (!in_thread_list (ptid) || is_exited (ptid)) add_thread (ptid);