From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 3/3] syscalls/tgkill03: add new test
Date: Sun, 16 Jun 2019 03:04:43 -0400 (EDT) [thread overview]
Message-ID: <847341899.28355719.1560668683548.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <CAEemH2cCvaPKa480Y3L5+V8ihRtwcTYZPo5ebU7Ss8tfRDXkuQ@mail.gmail.com>
----- Original Message -----
> On Sun, Jun 16, 2019 at 7:08 AM Jan Stancek <jstancek@redhat.com> wrote:
>
> >
> > ----- Original Message -----
> > > +static void setup(void)
> > > +{
> > > + sigset_t sigusr1;
> > > + pthread_t defunct_thread;
> > > +
> > > + sigemptyset(&sigusr1);
> > > + sigaddset(&sigusr1, SIGUSR1);
> > > + pthread_sigmask(SIG_BLOCK, &sigusr1, NULL);
> > > +
> > > + parent_tgid = getpid();
> > > + parent_tid = sys_gettid();
> > > +
> > > + SAFE_PTHREAD_CREATE(&child_thread, NULL, child_thread_func, NULL);
> > > +
> > > + TST_CHECKPOINT_WAIT(0);
> >
> > I'm seeing reports of this test failing on s390x:
> >
> > st_test.c:1096: INFO: Timeout per run is 0h 05m 00s
> > tgkill03.c:92: PASS: Invalid tgid failed as expected: EINVAL
> > tgkill03.c:92: PASS: Invalid tid failed as expected: EINVAL
> > tgkill03.c:92: PASS: Invalid signal failed as expected: EINVAL
> > tgkill03.c:96: FAIL: Defunct tid should have failed with ESRCH: SUCCESS
> > tgkill03.c:92: PASS: Defunct tgid failed as expected: ESRCH
> > tgkill03.c:99: PASS: Valid tgkill call succeeded
> >
> > and I suspect this piece:
> >
> > > +
> > > + SAFE_PTHREAD_CREATE(&defunct_thread, NULL, defunct_thread_func,
> > NULL);
> > > +
> > > + SAFE_PTHREAD_JOIN(defunct_thread, NULL);
> > > +}
> >
> > glibc pthread_join() waits for CLONE_CHILD_CLEARTID to clear tid,
> > and then resumes. Which kernel does at:
> > do_exit
> > exit_mm
> > mm_release
> > put_user(0, tsk->clear_child_tid);
> >
> > so there's still work to be done after that, and I suspect tid is still
> > valid
> > while that happens.
> >
> > My first idea: wait until /proc/pid/task/<tid> disappears.
> >
>
> The anaysis is probably right, but this idea doesn't work for me. Seems
> /proc/pid/task/<tid> is not the key point to confirm that tid has been
> clear.
>
> I just have a try as below:
>
> ===========
> # for i in `seq 1000`; do echo "i = $i" && ./tgkill03 || break; done
> ...
> i = 96
> tst_test.c:1112: INFO: Timeout per run is 0h 05m 00s
> tgkill03.c:106: FAIL: Defunct tid should have failed with ESRCH: SUCCESS
>
> ===========
> --- a/testcases/kernel/syscalls/tgkill/tgkill03.c
> +++ b/testcases/kernel/syscalls/tgkill/tgkill03.c
> @@ -5,6 +5,7 @@
> * Test simple tgkill() error cases.
> */
>
> +#include <stdio.h>
> #include <pthread.h>
> #include <pwd.h>
> #include <sys/types.h>
> @@ -19,6 +20,7 @@ static pid_t parent_tgid;
> static pid_t parent_tid;
> static pid_t child_tid;
> static pid_t defunct_tid;
> +char buf[1024];
>
> static const int invalid_pid = -1;
>
> @@ -35,6 +37,8 @@ static void *defunct_thread_func(void *arg)
> {
> defunct_tid = sys_gettid();
>
> + sprintf(buf, "/proc/pid/task/%d", defunct_tid);
How about?
sprintf(buf, "/proc/%d/task/%d", getpid(), defunct_tid);
next prev parent reply other threads:[~2019-06-16 7:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 6:49 [LTP] [PATCH v3 0/3] syscalls: add tgkill test-cases Sumit Garg
2019-03-19 6:49 ` [LTP] [PATCH v3 1/3] syscalls/tgkill01: add new test Sumit Garg
2019-03-19 13:55 ` Cyril Hrubis
2019-03-19 6:49 ` [LTP] [PATCH v3 2/3] syscalls/tgkill02: " Sumit Garg
2019-03-19 6:49 ` [LTP] [PATCH v3 3/3] syscalls/tgkill03: " Sumit Garg
2019-03-19 13:56 ` Cyril Hrubis
2019-06-15 23:08 ` Jan Stancek
2019-06-16 4:22 ` Li Wang
2019-06-16 7:04 ` Jan Stancek [this message]
2019-06-16 7:19 ` Li Wang
2019-03-19 13:54 ` [LTP] [PATCH v3 0/3] syscalls: add tgkill test-cases Cyril Hrubis
2019-03-20 7:43 ` Sumit Garg
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=847341899.28355719.1560668683548.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.com \
--cc=ltp@lists.linux.it \
/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.