All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Patrick Donnelly <pdonnel3@nd.edu>
Cc: Tejun Heo <tj@kernel.org>, linux-kernel@vger.kernel.org
Subject: Re: Question regarding ptrace work for LInux v3.1
Date: Mon, 21 Mar 2016 20:07:58 +0100	[thread overview]
Message-ID: <20160321190758.GA8230@redhat.com> (raw)
In-Reply-To: <CALJO4zGkwAq_yTBs98vxRsvVyJW5gYU5ntGPtrPj170Px_QtbQ@mail.gmail.com>

On 03/21, Patrick Donnelly wrote:
>
> That seems to be the case but it will only report certain events (not
> syscalls). I have observed PTRACE_EVENT_EXIT and PTRACE_EVENT_CLONE
> events... Hmm, now that I think about this, it would be necessary to
> see the initial SIGSTOP (or PTRACE_EVENT_STOP) in order to initiate
> syscall tracing via PTRACE_SYSCALL. So that does seem to indicate the
> problem.

Yes, exactly, you need to see the initial SIGSTOP or another event which
can be reported before it.

> > To clarify, the usage of SIGSTOP in ptrace was always buggy by design.
> > For example, SIGCONT from somewhere can remove the pending (and not yet
> > reported) SIGSTOP, and this _can_ explain the problem you hit.
>
> The tree of processes being traced do no send any signals but an
> external process may have.

I am looking into

   https://github.com/cooperative-computing-lab/cctools/blob/5ccb04599ba2ee125730981f53add80d98cf8161/parrot/src/pfs_main.cc

and this code

	case SIGSTOP:
	/* Black magic to get threads working on old Linux kernels... */

	if(p->nsyscalls == 0) { /* stop before we begin running the process */
		debug(D_DEBUG, "suppressing bootstrap SIGSTOP for %d",pid);
		signum = 0; /* suppress delivery */
		kill(p->pid,SIGCONT);
	}
	break;

doesn't look right. Note that kill(pid,SIGCONT) affects the whole thread-
group. So if this kill() races with another thread doing clone() you can
hit the problem you described.

> However, I did notice the use of futexes
> near these clones. Perhaps that may be causing this?

I don't think so,

> > But unless you use PTRACE_SEIZE the same can happen on v3.1 so it seems
> > there is something else.
>
> Okay, it might be that PTRACE_SEIZE fixes it.

Yes, but iiuc you do not see this problem on v3.1 even with PTRACE_ATTACH?

Oleg.

  reply	other threads:[~2016-03-21 19:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CALJO4zGaZBzCEHsD4oan=nhpQasmxWiN535RLM+2bXngcabQmA@mail.gmail.com>
2016-03-21 17:47 ` Question regarding ptrace work for LInux v3.1 Oleg Nesterov
2016-03-21 18:28   ` Patrick Donnelly
2016-03-21 19:07     ` Oleg Nesterov [this message]
2016-03-21 19:24       ` Patrick Donnelly
2016-03-21 19:35         ` Oleg Nesterov
2016-03-23 14:12           ` Patrick Donnelly

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=20160321190758.GA8230@redhat.com \
    --to=oleg@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pdonnel3@nd.edu \
    --cc=tj@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.