public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@mips.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: Sergey Korolev <s.korolev@ndmsystems.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH] MIPS/GDB/linux-nat.c: Fix a child detach condition for uClibc-ng
Date: Thu, 05 Jul 2018 12:32:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.00.1807051332020.22261@tp.orcam.me.uk> (raw)
In-Reply-To: <20180703193753.GC2675@embecosm.com>

On Tue, 3 Jul 2018, Andrew Burgess wrote:

> > Current implementation expects that WIFSTOPPED (W_STOPCODE (0)) is true,
> > but in the uClibc-ng it is false on MIPS. The patch adds a "detach"
> > helper variable to avoid this corner case: WIFSTOPPED applied
> > only to a status filled by a waitpid call that should never return
> > the status with zero stop signal.
> 
> I took a quick look through this patch, and have a little feedback.
> 
> You might want to expand your commit message to explain _why_ MIPS is
> different (having a signal 127), I didn't know this, and it puzzled me
> for a while as to why your above text didn't just indicate a bug in
> uClibc-ng :)

 I think it is a bug in uClibc-ng after all, because you can't receive 
signal #0 on Linux.  This is what the kernel has (in kernel/signal.c):

		/*
		 * The null signal is a permissions and process existence
		 * probe.  No signal is actually delivered.
		 */
		if (!error && sig) {
			error = do_send_sig_info(sig, info, p, false);
			/*
			 * If lock_task_sighand() failed we pretend the task
			 * dies after receiving the signal. The window is tiny,
			 * and the signal is private anyway.
			 */
			if (unlikely(error == -ESRCH))
				error = 0;
		}

and also:

	if (!ret && sig)
		ret = do_send_sig_info(sig, info, p, true);

and documentation for kill(2) agrees:

      "If  sig  is 0, then no signal is sent, but error checking is still per-
       formed; this can be used to check for the existence of a process ID  or
       process group ID."

> [PATCH] gdb: Avoid using W_STOPCODE(0) as this is ambiguous on MIPS
> 
> The MIPS target supports 127 signals, and this can create an ambiguity
> in process wait statuses.  A status value of 0x007f could potentially
> indicate a process that has exited with signal 127, or a process that
> has stopped with signal 0.
> 
> In uClibc-ng the interpretation of 0x007f is that the process has
> exited with signal 127 rather than stopped with signal 0, and so,
> WIFSTOPPED (W_STOPCODE (0)) will be false rather than true as it would
> be on most other platforms.

 So there is no ambiguity, 0x007f means that the process has exited with 
signal 127 and nothing else, and while I agree the change might be a good 
workaround for uClibc-ng's oddity, I think uClibc-ng's implementation of 
WIFSTOPPED has also to be fixed to reflect reality.  Which also means the 
commit description needs to be updated accordingly.

 FWIW,

  Maciej

  parent reply	other threads:[~2018-07-05 12:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-14 22:54 Sergey Korolev
2018-07-03 19:38 ` Andrew Burgess
2018-07-04 13:36   ` Sergey Korolev
2018-07-05 12:32   ` Maciej W. Rozycki [this message]
2018-07-05 21:05     ` Sergey Korolev
2018-07-06 22:10     ` Andrew Burgess
2018-07-09 11:20       ` Maciej W. Rozycki
2018-08-01 21:31   ` Ping! " Andrew Burgess
2018-08-01 21:38     ` Sergey Korolev
2018-08-02 20:03       ` Tom Tromey

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=alpine.DEB.2.00.1807051332020.22261@tp.orcam.me.uk \
    --to=macro@mips.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=s.korolev@ndmsystems.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).