This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/17707] New: nptl_db: terminated and joined threads


https://sourceware.org/bugzilla/show_bug.cgi?id=17707

            Bug ID: 17707
           Summary: nptl_db: terminated and joined threads
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
          Assignee: unassigned at sourceware dot org
          Reporter: palves at redhat dot com
                CC: drepper.fsp at gmail dot com

I wrote a GDB test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues.  This is one of
them.

GDB sometimes prints out a warning like:

 ...
 [New LWP 20700]
 warning: unable to open /proc file '/proc/-1/status'
 [New LWP 20850]
 [New LWP 21019]
 ...

That happens because when a thread exits, and is joined, glibc does:

nptl/pthread_join.c:
pthread_join ()
{
...
  if (__glibc_likely (result == 0))
    {
      /* We mark the thread as terminated and as joined.  */
      pd->tid = -1;
...
     /* Free the TCB.  */
      __free_tcb (pd);
    }

So if we stop the inferior at just the right time, and list threads
with td_ta_thr_iter / td_thr_get_info, we can find threads with kernel thread
ID -1 (td_thrinfo_t.ti_lid == -1).

Unfortunately, td_thrinfo_t.ti_state claims the thread is TD_THR_ACTIVE.
Turns out the set of states td_thr_get_info returns isn't very
complete:

 td_thr_get_info ()
 {
   if ((((int) (uintptr_t) cancelhandling) & EXITING_BITMASK) == 0)
     /* XXX For now there is no way to get more information.  */
     infop->ti_state = TD_THR_ACTIVE;
   else if ((((int) (uintptr_t) cancelhandling) & TERMINATED_BITMASK) == 0)
     infop->ti_state = TD_THR_ZOMBIE;
   else
     infop->ti_state = TD_THR_UNKNOWN;

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]