This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
posix/tst-waitid.c possible race condition on Linux
- From: Olivier Langlois <olivier at trillion01 dot com>
- To: libc-alpha at sourceware dot org
- Date: Wed, 12 Jun 2013 00:39:30 -0400
- Subject: posix/tst-waitid.c possible race condition on Linux
Hi,
Not sure if IEEE Std 1003.1 say something about this but I am
experiencing intermittent failure of this test.
very intermittant Output:
missing SIGCHLD on stopped
It seems to happen here:
/* Now stop him again and test waitpid with WCONTINUED. */
expecting_sigchld = 1;
if (kill (pid, SIGSTOP) != 0)
{
printf ("kill (%d, SIGSTOP): %m\n", pid);
RETURN (EXIT_FAILURE);
}
pid_t wpid = waitpid (pid, &fail, WUNTRACED);
if (wpid < 0)
{
printf ("waitpid WUNTRACED on stopped: %m\n");
RETURN (EXIT_FAILURE);
}
else if (wpid != pid)
{
printf ("waitpid WUNTRACED on stopped returned %d != %d (status %
x)\n",
wpid, pid, fail);
RETURN (EXIT_FAILURE);
}
else if (!WIFSTOPPED (fail) || WIFSIGNALED (fail) || WIFEXITED (fail)
|| WIFCONTINUED (fail) || WSTOPSIG (fail) != SIGSTOP)
{
printf ("waitpid WUNTRACED on stopped: status %x\n", fail);
RETURN (EXIT_FAILURE);
}
CHECK_SIGCHLD ("stopped", CLD_STOPPED, SIGSTOP);
IEEE Std 1003.1 specify the following guaranty
When SA_SIGINFO is requested, the SIGCHLD signal handler can be
guaranteed to receive a non-NULL pointer to a siginfo_t structure that
describes a child process for which a wait via waitpid() or waitid()
will not block or fail.
but says nothing about having SIGCHLD handler being called upon
waitpid() return and that is exactly what is happening occasionnally.
To increase probability to see the problem, I think that having a kernel
with CONFIG_PREEMPT and HZ >= 1000 do help.
I might attempt to propose a change for the test but just wanted to test
the water here to see if what others think about the error that I am
seeing.