This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Fix crash on /proc/PID/stat race
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Date: Thu, 27 May 2010 20:00:26 +0100
- Subject: Re: [patch] Fix crash on /proc/PID/stat race
- References: <20100527175404.GA16087@host0.dyn.jankratochvil.net>
On Thursday 27 May 2010 18:54:04, Jan Kratochvil wrote:
> Hi,
>
> got a reported a core file that gdb crashes in linux_nat_core_of_thread_1
> called from linux_nat_wait_1 on TARGET_WAITKIND_EXITED. It crashes because
> CONTENT is empty there.
>
> While it is understanable /proc/PID/stat is not available after
> TARGET_WAITKIND_EXITED I failed to artificially reproduce it by
> sleep 1&p=$!;(sleep 2;cat) </proc/$p/stat
> as it prints
> cat: -: No such process
> due to
> read(0, 0x65d000, 32768) = -1 ESRCH (No such process)
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?
--
Pedro Alves