This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Darwin 2/4] Do not crash (failed assertion) after PT_KILL ptrace error
> From: Joel Brobecker <brobecker@adacore.com>
> Date: Fri, 1 Jul 2011 12:03:24 -0700
>
> This is something I noticed while reading the code. Putting an
> assertion that the PT_KILL ptrace call never returns an error
> is too strong. It might not be a debugger bug that caused the
> PT_KILL ptrace operation to fail, so a failed-assertion "crash"
> would not be justified. It also seems easy enough to continue
> and get ready for the next debugging session. So this patch
> changes the assertion into a warning.
>
> This patch also tries to handle the case where ptrace return -1,
> but left errno set to zero. According to the ptrace man page,
> it is possible for some ptrace operations to return -1 in non-error
> situations, and to detect those situations, it explains that errno
> should be set prior to calling ptrace, and then checked again after.
I think I disagree here. PT_KILL should only fail if you pass it the
wrong process ID. So unless there is an OS bug of some sorts, this is
going to be a GDB internal error. Do you have actual evidence there
is a kernel bug here?
> gdb/ChangeLog:
>
> * darwin-nat.c (darwin_ptrace): Add documentation.
> Set errno to zero before calling ptrace. If ptrace returns
> -1 and errno is zero, then change then return zero.
> (darwin_kill_inferior): Issue a warning instead of triggering
> a failed assertion when the PT_KILL ptrace operations returned
> nonzero.