From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32617 invoked by alias); 22 Sep 2011 22:30:01 -0000 Received: (qmail 32521 invoked by uid 22791); 22 Sep 2011 22:29:59 -0000 X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_TP X-Spam-Check-By: sourceware.org Received: from mail-ey0-f169.google.com (HELO mail-ey0-f169.google.com) (209.85.215.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Sep 2011 22:29:43 +0000 Received: by eye13 with SMTP id 13so2138779eye.0 for ; Thu, 22 Sep 2011 15:29:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.108.132 with SMTP id f4mr1513937ebp.32.1316730582177; Thu, 22 Sep 2011 15:29:42 -0700 (PDT) Received: by 10.213.104.136 with HTTP; Thu, 22 Sep 2011 15:29:42 -0700 (PDT) Date: Thu, 22 Sep 2011 22:30:00 -0000 Message-ID: Subject: Re: Thread exit error : gdb7.2 in FreeBSD (built from ports) From: John Schumacher To: Pedro Alves Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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/msg00098.txt.bz2 On Thu, Sep 22, 2011 at 12:11 PM, Pedro Alves wrot= e: I still don't understand this. =C2=A0If this thread has exited before, then why is the backend reporting a TARGET_WAITKIND_STOPPED for it now? =C2=A0Did a new thread reappear later out of nothing that reuses the same ID, description and all? If by magic that's the case, then it's this bit in infrun.c:handle_inferior_event: =C2=A0/* If it's a new process, add it to the thread database. =C2=A0*/ =C2=A0ecs->new_thread_event =3D (!ptid_equal (ecs->ptid, inferior_ptid) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 && !ptid_equal (ecs->ptid, minus_one_ptid) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 && !in_thread_list (ecs->ptid)); =C2=A0if (ecs->ws.kind !=3D TARGET_WAITKIND_EXITED =C2=A0 =C2=A0 =C2=A0&& ecs->ws.kind !=3D TARGET_WAITKIND_SIGNALLED && ecs->= new_thread_event) =C2=A0 =C2=A0add_thread (ecs->ptid); in_thread_list returns true for an exited thread, but we should end up in add_thread as well if ecs->ptid is in the thread list marked exited. -- Pedro Alves You might be on to something. I set a breakpoint at the handle_inferior_event function in infrun.c Notice that we handle an event for ptid.tid 100269, then proceed to delete_thread_1. The next breakpoint we hit is for the same thread which we had flagged as exited ptid.tid 100269. In fact, we encounter 2 of these events in a row. We then proceed to hit the error in get_current_frame. (gdb) c Continuing. Breakpoint 7, handle_inferior_event (ecs=3D0x7fffffffe300) at infrun.c:2989 2989 =C2=A0 =C2=A0 =C2=A0ecs->event_thread =3D find_thread_ptid (ecs->ptid); (gdb) p *ecs $109 =3D { =C2=A0 ptid =3D { =C2=A0 =C2=A0 pid =3D 1611, =C2=A0 =C2=A0 lwp =3D 0, =C2=A0 =C2=A0 tid =3D 100269 =C2=A0 }, =C2=A0 event_thread =3D 0x803eade40, =C2=A0 ws =3D { =C2=A0 =C2=A0 kind =3D TARGET_WAITKIND_STOPPED, =C2=A0 =C2=A0 value =3D { =C2=A0 =C2=A0 =C2=A0 integer =3D 5, =C2=A0 =C2=A0 =C2=A0 sig =3D TARGET_SIGNAL_TRAP, =C2=A0 =C2=A0 =C2=A0 related_pid =3D { =C2=A0 =C2=A0 =C2=A0 =C2=A0 pid =3D 5, =C2=A0 =C2=A0 =C2=A0 =C2=A0 lwp =3D 0, =C2=A0 =C2=A0 =C2=A0 =C2=A0 tid =3D 0 =C2=A0 =C2=A0 =C2=A0 }, =C2=A0 =C2=A0 =C2=A0 execd_pathname =3D 0x5 Address 0x5 out of bounds, =C2=A0 =C2=A0 =C2=A0 syscall_number =3D 5 =C2=A0 =C2=A0 } =C2=A0 }, =C2=A0 random_signal =3D 0, =C2=A0 stop_func_start =3D 0, =C2=A0 stop_func_end =3D 0, =C2=A0 stop_func_name =3D 0x0, =C2=A0 new_thread_event =3D 0, =C2=A0 wait_some_more =3D 1 } (gdb) p *ecs $110 =3D { =C2=A0 ptid =3D { =C2=A0 =C2=A0 pid =3D 1611, =C2=A0 =C2=A0 lwp =3D 0, =C2=A0 =C2=A0 tid =3D 100269 =C2=A0 }, =C2=A0 event_thread =3D 0x803eade40, =C2=A0 ws =3D { =C2=A0 =C2=A0 kind =3D TARGET_WAITKIND_STOPPED, =C2=A0 =C2=A0 value =3D { =C2=A0 =C2=A0 =C2=A0 integer =3D 5, =C2=A0 =C2=A0 =C2=A0 sig =3D TARGET_SIGNAL_TRAP, =C2=A0 =C2=A0 =C2=A0 related_pid =3D { =C2=A0 =C2=A0 =C2=A0 =C2=A0 pid =3D 5, =C2=A0 =C2=A0 =C2=A0 =C2=A0 lwp =3D 0, =C2=A0 =C2=A0 =C2=A0 =C2=A0 tid =3D 0 =C2=A0 =C2=A0 =C2=A0 }, =C2=A0 =C2=A0 =C2=A0 execd_pathname =3D 0x5 Address 0x5 out of bounds, =C2=A0 =C2=A0 =C2=A0 syscall_number =3D 5 =C2=A0 =C2=A0 } =C2=A0 }, =C2=A0 random_signal =3D 0, =C2=A0 stop_func_start =3D 0, =C2=A0 stop_func_end =3D 0, =C2=A0 stop_func_name =3D 0x0, =C2=A0 new_thread_event =3D 0, =C2=A0 wait_some_more =3D 1 } (gdb) c Continuing. Breakpoint 1, delete_thread_1 (ptid=3D..., silent=3D0) at thread.c:247 247 =C2=A0 =C2=A0 =C2=A0 tpprev =3D NULL; (gdb) c Continuing. Breakpoint 6, handle_inferior_event (ecs=3D0x7fffffffe300) at infrun.c:2981 2981 =C2=A0 =C2=A0 =C2=A0ecs->new_thread_event =3D (!ptid_equal (ecs->ptid,= inferior_ptid) (gdb) p *ecs $111 =3D { =C2=A0 ptid =3D { =C2=A0 =C2=A0 pid =3D 1611, =C2=A0 =C2=A0 lwp =3D 0, =C2=A0 =C2=A0 tid =3D 100269 =C2=A0 }, =C2=A0 event_thread =3D 0x8225bb940, =C2=A0 ws =3D { =C2=A0 =C2=A0 kind =3D TARGET_WAITKIND_STOPPED, =C2=A0 =C2=A0 value =3D { =C2=A0 =C2=A0 =C2=A0 integer =3D 5, =C2=A0 =C2=A0 =C2=A0 sig =3D TARGET_SIGNAL_TRAP, =C2=A0 =C2=A0 =C2=A0 related_pid =3D { =C2=A0 =C2=A0 =C2=A0 =C2=A0 pid =3D 5, =C2=A0 =C2=A0 =C2=A0 =C2=A0 lwp =3D 0, =C2=A0 =C2=A0 =C2=A0 =C2=A0 tid =3D 0 =C2=A0 =C2=A0 =C2=A0 }, =C2=A0 =C2=A0 =C2=A0 execd_pathname =3D 0x5 Address 0x5 out of bounds, =C2=A0 =C2=A0 =C2=A0 syscall_number =3D 5 =C2=A0 =C2=A0 } =C2=A0 }, =C2=A0 random_signal =3D 0, =C2=A0 stop_func_start =3D 34388142208, =C2=A0 stop_func_end =3D 34388142210, =C2=A0 stop_func_name =3D 0x8018c13c5 "_thread_bp_death", =C2=A0 new_thread_event =3D 0, =C2=A0 wait_some_more =3D 1 } (gdb) (gdb) c Continuing. Breakpoint 7, handle_inferior_event (ecs=3D0x7fffffffe300) at infrun.c:2989 2989 =C2=A0 =C2=A0 =C2=A0ecs->event_thread =3D find_thread_ptid (ecs->ptid); (gdb) p *ecs $112 =3D { =C2=A0 ptid =3D { =C2=A0 =C2=A0 pid =3D 1611, =C2=A0 =C2=A0 lwp =3D 0, =C2=A0 =C2=A0 tid =3D 100269 =C2=A0 }, =C2=A0 event_thread =3D 0x8225bb940, =C2=A0 ws =3D { =C2=A0 =C2=A0 kind =3D TARGET_WAITKIND_STOPPED, =C2=A0 =C2=A0 value =3D { =C2=A0 =C2=A0 =C2=A0 integer =3D 5, =C2=A0 =C2=A0 =C2=A0 sig =3D TARGET_SIGNAL_TRAP, =C2=A0 =C2=A0 =C2=A0 related_pid =3D { =C2=A0 =C2=A0 =C2=A0 =C2=A0 pid =3D 5, =C2=A0 =C2=A0 =C2=A0 =C2=A0 lwp =3D 0, =C2=A0 =C2=A0 =C2=A0 =C2=A0 tid =3D 0 =C2=A0 =C2=A0 =C2=A0 }, =C2=A0 =C2=A0 =C2=A0 execd_pathname =3D 0x5 Address 0x5 out of bounds, =C2=A0 =C2=A0 =C2=A0 syscall_number =3D 5 =C2=A0 =C2=A0 } =C2=A0 }, =C2=A0 random_signal =3D 0, =C2=A0 stop_func_start =3D 34388142208, =C2=A0 stop_func_end =3D 34388142210, =C2=A0 stop_func_name =3D 0x8018c13c5 "_thread_bp_death", =C2=A0 new_thread_event =3D 0, =C2=A0 wait_some_more =3D 1 } (gdb) c Continuing. Breakpoint 3, get_current_frame () at frame.c:1177 1177 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0error (_("Invalid selected thread.")= ); (gdb) where #0 =C2=A0get_current_frame () at frame.c:1179 #1 =C2=A00x000000000053d5f4 in handle_inferior_event (ecs=3D0x7fffffffe300) at infrun.c:3697 #2 =C2=A00x000000000053ae53 in wait_for_inferior (treat_exec_as_sigtrap=3D0) at infrun.c:2551 #3 =C2=A00x000000000053a12c in proceed (addr=3D34386749296, siggnal=3DTARGET_SIGNAL_0, step=3D0) at infrun.c:2064 This is very suspicious. Is FreeBSD calling into gdb twice for an exiting thread? The first time, we are flagging it as exited, and getting caught up in the get_current_frame() the second time? Is fbsd-threads.c the one who is calling into gdb? Or how does that relationship work? Thanks again -John -- John Schumacher