Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix crash on /proc/PID/stat race
Date: Thu, 27 May 2010 21:24:00 -0000	[thread overview]
Message-ID: <20100527212037.GA24735@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <201005272000.26518.pedro@codesourcery.com>

On Thu, 27 May 2010 21:00:26 +0200, Pedro Alves wrote:
> Why are we trying to get at the core if we know the process
> is gone?  Since the process is already waited for, I'm surprised
> the fopen succeeded in the first place.  On a couple of quick tests,
> I always see fopen failing.  It sounds like a kernel bug.  Can't we
> just skip the core_of_thread call for
> TARGET_WAITKING_EXITED|TARGET_WAITKING_SIGNALLED?

An additional patch like this one?

It is IMO not correct for GDB to crash on unexpected /proc/** content.


Thanks,
Jan


2010-05-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
(maybe rather Pedro Alves  <pedro@codesourcery.com> as I just "installed" it)

	* linux-nat.c (linux_nat_wait_1): Do not call
	linux_nat_core_of_thread_1 on TARGET_WAITKIND_EXITED or
	TARGET_WAITKIND_SIGNALLED.

--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -3626,7 +3626,13 @@ retry:
     fprintf_unfiltered (gdb_stdlog, "LLW: exit\n");
 
   restore_child_signals_mask (&prev_mask);
-  lp->core = linux_nat_core_of_thread_1 (lp->ptid);
+
+  if (ourstatus->kind == TARGET_WAITKIND_EXITED
+      || ourstatus->kind == TARGET_WAITKIND_SIGNALLED)
+    lp->core = -1;
+  else
+    lp->core = linux_nat_core_of_thread_1 (lp->ptid);
+
   return lp->ptid;
 }
 


  reply	other threads:[~2010-05-27 21:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 18:00 Jan Kratochvil
2010-05-27 19:06 ` Pedro Alves
2010-05-27 21:24   ` Jan Kratochvil [this message]
2010-05-27 22:50     ` Pedro Alves
2010-05-28 18:28       ` Jan Kratochvil

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=20100527212037.GA24735@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.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