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 for power-pc gdb.server/non-existing-program.exp


Carl Love wrote:

> Fix for power-pc gdb.server/non-existing-program.exp
> 
> The ptrace function reports an error when it is called on a process that
> has already terminated.  This commit fixes the issue by checking in function
> ppc_arch_setup() and returning without fetching the registers for the
> inferior.

This doesn't look like the right place to fix the underlying problem.

Note that for one thing, your patch would one make the race condition
window smaller and harder to hit (the process could terminate between
the new check and the ptrace call).

The real problem is that arch_setup, like most of the low-target routines
really should only ever be called when the inferior is stopped during a
ptrace intercept.  In that status, the inferior cannot simply go away --
this is exactly so that we avoid races while interacting with a process
via ptrace.

So the real question is, what's the code path that calls arch_setup at
a point where the inferior is *not* in a stable state (stopped during
a ptrace intercept)?

> +  tid = lwpid_of (current_thread);
> +  if (getpgid(tid) <= 0) {
> +	  /* process doesn't exist, exit or subsequent call to ptrace will fail
> +		  on on-existent process */
> +	  fflush(stdout);
> +     return;
> +  }

Just as an aside, there's a number of other issues in here:
- What's the point of the fflush call?
- Coding style requires a space before the '(' of a function call.
- Comments should be full sentences, with a capital initial letter
  and a full stop '.' at the end (and two spaces after the full stop).
- Opening '{' goes on the next line, indented by two.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


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