Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [gdbserver] Problems trying to resume dead threads
Date: Mon, 04 Aug 2008 13:40:00 -0000	[thread overview]
Message-ID: <20080804134000.GA17925@caradoc.them.org> (raw)
In-Reply-To: <200807191716.m6JHGmsA013958@d12av02.megacenter.de.ibm.com>

Sorry - as you can see, I am once again behind on gdb-patches.

On Sat, Jul 19, 2008 at 07:16:48PM +0200, Ulrich Weigand wrote:
> Hello,
> 
> gdbserver on Linux seems to have difficulties handling
> the case where a thread dies while it is stopped.  This can
> happen during the loop over all threads in linux_resume:

I can reproduce this problem by using the binary from killed.exp and
running strace on gdbserver.  I can also reproduce it on an embedded
ARM target by running killed.exp.  I can't reproduce it on my desktop
running killed.exp, which suggests this is normally hidden by
scheduler decisions - you need a long enough gap between the two
PTRACE_CONT's.

What do you think of this change?  Ideally, we could wait with WNOHANG
at this point to check for the exit case, but we'd have to restructure
a bit of the event loop to handle pending status == exited.

-- 
Daniel Jacobowitz
CodeSourcery

2008-08-04  Daniel Jacobowitz  <dan@codesourcery.com>

	* linux-low.c (linux_resume_one_process): Ignore ESRCH.

Index: linux-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v
retrieving revision 1.79
diff -u -p -r1.79 linux-low.c
--- linux-low.c	28 Jul 2008 18:28:56 -0000	1.79
+++ linux-low.c	4 Aug 2008 13:38:24 -0000
@@ -1193,7 +1193,19 @@ linux_resume_one_process (struct inferio
 
   current_inferior = saved_inferior;
   if (errno)
-    perror_with_name ("ptrace");
+    {
+      /* ESRCH from ptrace either means that the thread was already
+	 running (an error) or that it is gone (a race condition).  If
+	 it's gone, we will get a notification the next time we wait,
+	 so we can ignore the error.  We could differentiate these
+	 two, but it's tricky without waiting; the thread still exists
+	 as a zombie, so sending it signal 0 would succeed.  So just
+	 ignore ESRCH.  */
+      if (errno == ESRCH)
+	return;
+
+      perror_with_name ("ptrace");
+    }
 }
 
 static struct thread_resume *resume_ptr;


  reply	other threads:[~2008-08-04 13:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-19 17:17 Ulrich Weigand
2008-08-04 13:40 ` Daniel Jacobowitz [this message]
2008-08-04 18:25   ` Ulrich Weigand
2008-08-04 18:30     ` Daniel Jacobowitz
2008-08-04 19:46       ` Ulrich Weigand
2008-08-04 19:55         ` Daniel Jacobowitz
2008-08-05 21:06           ` Ulrich Weigand
2008-08-05 21:59             ` Daniel Jacobowitz
2008-08-05 22:15               ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080804134000.GA17925@caradoc.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox