Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH]: linux and zombie threads
@ 2001-05-22 17:07 Michael Snyder
  2001-05-23  4:49 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Snyder @ 2001-05-22 17:07 UTC (permalink / raw)
  To: gdb-patches

Mark -- these changes prepare the way for a libthread_db change
that will allow gdb to recognize zombie threads.
2001-05-22  Michael Snyder  <msnyder@redhat.com>

	* thread-db.c: Allow for defunct zombie threads.	
	(attach_thread): Do not attempt to attach zombie thread.
	(thread_db_thread_alive): Return false for defunct zombie thread.
	(find_new_threads_callback): Don't add defunct zombie thread to list.

Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/thread-db.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 thread-db.c
*** thread-db.c	2001/05/15 00:03:36	1.13
--- thread-db.c	2001/05/23 00:05:41
*************** attach_thread (ptid_t ptid, const td_thr
*** 573,578 ****
--- 573,581 ----
    tp->private = xmalloc (sizeof (struct private_thread_info));
    tp->private->lwpid = ti_p->ti_lid;
  
+   if (ti_p->ti_state == TD_THR_UNKNOWN)
+     return;/* A zombie thread that's been joined -- do not attach. */
+ 
    /* Under Linux, we have to attach to each and every thread.  */
  #ifdef ATTACH_LWP
    ATTACH_LWP (BUILD_LWP (ti_p->ti_lid, GET_PID (ptid)), 0);
*************** thread_db_mourn_inferior (void)
*** 894,904 ****
  static int
  thread_db_thread_alive (ptid_t ptid)
  {
    if (is_thread (ptid))
      {
-       td_thrhandle_t th;
-       td_err_e err;
- 
        err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th);
        if (err != TD_OK)
  	return 0;
--- 897,908 ----
  static int
  thread_db_thread_alive (ptid_t ptid)
  {
+   td_thrhandle_t th;
+   td_thrinfo_t   ti;
+   td_err_e       err;
+ 
    if (is_thread (ptid))
      {
        err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th);
        if (err != TD_OK)
  	return 0;
*************** thread_db_thread_alive (ptid_t ptid)
*** 907,912 ****
--- 911,923 ----
        if (err != TD_OK)
  	return 0;
  
+       err = td_thr_get_info_p (&th, &ti);
+       if (err != TD_OK)
+ 	return 0;
+ 
+       if (ti.ti_state == TD_THR_UNKNOWN)
+ 	return 0;	/* A zombie thread that's been joined. */
+ 
        return 1;
      }
  
*************** find_new_threads_callback (const td_thrh
*** 926,931 ****
--- 937,945 ----
    err = td_thr_get_info_p (th_p, &ti);
    if (err != TD_OK)
      error ("Cannot get thread info: %s", thread_db_err_str (err));
+ 
+   if (ti.ti_state == TD_THR_UNKNOWN)
+     return 0;	/* A zombie that's been reaped -- ignore. */
  
    ptid = BUILD_THREAD (ti.ti_tid, GET_PID (inferior_ptid));
  
From kevinb@cygnus.com Tue May 22 17:53:00 2001
From: Kevin Buettner <kevinb@cygnus.com>
To: Jim Blandy <jimb@cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH RFA #2] breakpoint.c: More check_duplicates() changes
Date: Tue, 22 May 2001 17:53:00 -0000
Message-id: <1010523005321.ZM29277@ocotillo.lan>
References: <1010512223535.ZM30908@ocotillo.lan> <npr8xh0xv9.fsf@zwingli.cygnus.com> <1010522235055.ZM29150@ocotillo.lan> <kevinb@cygnus.com>
X-SW-Source: 2001-05/msg00424.html
Content-length: 216

On May 22,  4:50pm, Kevin Buettner wrote:

> 	* breakpoint.c (breakpoint_address_is_meaningful): New function.
> 	(check_duplicates): Don't compare non-meaningful addresses.

I've just committed this change.

Kevin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH]: linux and zombie threads
  2001-05-22 17:07 [PATCH]: linux and zombie threads Michael Snyder
@ 2001-05-23  4:49 ` Mark Kettenis
  2001-05-23 19:14   ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2001-05-23  4:49 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches

Michael Snyder <msnyder@cygnus.com> writes:

> Mark -- these changes prepare the way for a libthread_db change
> that will allow gdb to recognize zombie threads.

Hmm, what do you mean with zombie threads when you're talking about a
libthread_db change?

For clarity, it seems to be two concepts of "zombie" related to
LinuxThreads.  One is which I would call a "zombie thread", which
basically is a thread that has exited (by invoking pthread_exit() or
returning from the, but has not yet been joined.  These are reported
by libthread_db as TD_THR_ZOMBIE.

The other I would call a "zombie process", which basically is a kernel
thread that has exited (by invoking _exit()) but has not yet been
waited for.  These are the ondes reported as TD_THR_UNKNOWN.  Their
existence is very Linux-specific, and the fact that they tend to show
up when debugging is related to a kernel bug for which I have been
unable to find a kernel hacker to fix.

> 2001-05-22  Michael Snyder  <msnyder@redhat.com>
> 
> 	* thread-db.c: Allow for defunct zombie threads.	
> 	(attach_thread): Do not attempt to attach zombie thread.
> 	(thread_db_thread_alive): Return false for defunct zombie thread.
> 	(find_new_threads_callback): Don't add defunct zombie thread to list.

That said, I think your patch is OK.  We want GDB to ignore the
"zombie processes".  Practically all Linux kernels contain the bug
that creates them, and even if the bug was fixed, there probably is a
small window where these "zombie processes" are visible.

Could you clean up your patch a bit before checking it in?  There seem
to be some whitespace/indentation problems.  And lining up the local
variables in thread_db_thread_alive() seems to be against the coding
standards too (since it introduces unnecessary whitespace).

Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH]: linux and zombie threads
  2001-05-23  4:49 ` Mark Kettenis
@ 2001-05-23 19:14   ` Michael Snyder
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Snyder @ 2001-05-23 19:14 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: Michael Snyder, gdb-patches

Mark Kettenis wrote:
> 
> Michael Snyder <msnyder@cygnus.com> writes:
> 
> > Mark -- these changes prepare the way for a libthread_db change
> > that will allow gdb to recognize zombie threads.
> 
> Hmm, what do you mean with zombie threads when you're talking about a
> libthread_db change?
> 
> For clarity, it seems to be two concepts of "zombie" related to
> LinuxThreads.  One is which I would call a "zombie thread", which
> basically is a thread that has exited (by invoking pthread_exit() or
> returning from the, but has not yet been joined.  These are reported
> by libthread_db as TD_THR_ZOMBIE.

Yes.

> The other I would call a "zombie process", which basically is a kernel
> thread that has exited (by invoking _exit()) but has not yet been
> waited for.  These are the ondes reported as TD_THR_UNKNOWN.  Their
> existence is very Linux-specific, and the fact that they tend to show
> up when debugging is related to a kernel bug for which I have been
> unable to find a kernel hacker to fix.

These also show up when a thread has exited and has been
pthread_joined.  I'm sure it's a kernel bug, but without 
these changes, it gets GDB all screwed up.

> 
> > 2001-05-22  Michael Snyder  <msnyder@redhat.com>
> >
> >       * thread-db.c: Allow for defunct zombie threads.
> >       (attach_thread): Do not attempt to attach zombie thread.
> >       (thread_db_thread_alive): Return false for defunct zombie thread.
> >       (find_new_threads_callback): Don't add defunct zombie thread to list.
> 
> That said, I think your patch is OK.  We want GDB to ignore the
> "zombie processes".  Practically all Linux kernels contain the bug
> that creates them, and even if the bug was fixed, there probably is a
> small window where these "zombie processes" are visible.
> 
> Could you clean up your patch a bit before checking it in?  There seem
> to be some whitespace/indentation problems.  And lining up the local
> variables in thread_db_thread_alive() seems to be against the coding
> standards too (since it introduces unnecessary whitespace).
> 
> Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-05-23 19:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-22 17:07 [PATCH]: linux and zombie threads Michael Snyder
2001-05-23  4:49 ` Mark Kettenis
2001-05-23 19:14   ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox