From: Oleg Nesterov <oleg@redhat.com>
To: Pavel Labath <labath@google.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: A peculiarity in ptrace/waitpid behavior
Date: Fri, 20 Mar 2015 17:25:48 +0100 [thread overview]
Message-ID: <20150320162548.GA21069@redhat.com> (raw)
In-Reply-To: <CAJt8pk-+UGsmAzA8cTn3deWfSrDAy__Yh=bqi4_NRqJVhg63JQ@mail.gmail.com>
Hi Pavel,
let me add lkml, we should not discuss this offlist.
On 03/20, Pavel Labath wrote:
>
> 1) we get a waitpid() notification that the tracee got SIGUSR1
> 2) we do a ptrace(GETSIGINFO) to get more info
> 3) eventually we decide to restart the tracee with PTRACE_CONT, passing it
> SIGUSR1
> 4) immediately after that we get another waitpid notification, again with
> SIGUSR1, even though the thread had received no additional signals
> 5) we again try to a GETSIGINFO, however this time it fails with ESRCH.
> Therefore, we assume that the thread has died
I found a similar bug by code inspection some time ago. I even have
a fix, but I need to think more... And I even wrote the test-case ;)
see below.
But so far I can't say if you hit the same problem or not. If you can
reproduce the problem, perhaps I can send you debugging patch?
Oleg.
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/ptrace.h>
#include <sys/syscall.h>
#include <assert.h>
#define tkill(pid, sig) \
syscall(__NR_tkill, pid, sig)
void run_test(void)
{
int pid, stat;
pid = fork();
if (!pid) {
assert(ptrace(PTRACE_TRACEME, 0,0,0) == 0);
raise(SIGSTOP);
assert(0);
}
assert(pid == wait(&stat) && stat == 0x137f);
tkill(pid, SIGTRAP); /* should not be reported */
tkill(pid, SIGKILL);
assert(pid == wait(&stat));
if (stat == 0x9)
return;
printf("unexpected wait: stat=%x\n", stat);
kill(0, SIGKILL);
}
int main(void)
{
int i = 8; /* random */
while (--i)
if (!fork())
break;
for (;;)
run_test();
return 0;
}
next parent reply other threads:[~2015-03-20 16:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAJt8pk-+UGsmAzA8cTn3deWfSrDAy__Yh=bqi4_NRqJVhg63JQ@mail.gmail.com>
2015-03-20 16:25 ` Oleg Nesterov [this message]
[not found] ` <CAJt8pk8-=xV_Tofr2W7jT8kLX-GseEeL5d2+w0U4zv2QqnP6rQ@mail.gmail.com>
2015-03-20 18:53 ` A peculiarity in ptrace/waitpid behavior Pavel Labath
2015-03-21 18:57 ` Oleg Nesterov
2015-03-22 15:33 ` Oleg Nesterov
2015-03-23 9:42 ` Pavel Labath
2015-03-24 16:53 ` Pavel Labath
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=20150320162548.GA21069@redhat.com \
--to=oleg@redhat.com \
--cc=labath@google.com \
--cc=linux-kernel@vger.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 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 NNTP newsgroup(s).