This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

Re: [patch] Fix crash on /proc/PID/stat race


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;
 }
 


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