[Bugme-new] [Bug 32922] New: futex_wait() may ignore the timeout if interrupted by a signal
bugzilla-daemon at bugzilla.kernel.org
bugzilla-daemon at bugzilla.kernel.org
Fri Apr 8 18:34:58 PDT 2011
https://bugzilla.kernel.org/show_bug.cgi?id=32922
Summary: futex_wait() may ignore the timeout if interrupted by
a signal
Product: Other
Version: 2.5
Kernel Version: 2.6.38.2
Platform: All
OS/Version: Linux
Tree: Mainline
Status: NEW
Severity: low
Priority: P1
Component: Other
AssignedTo: other_other at kernel-bugs.osdl.org
ReportedBy: tsmith201104 at yahoo.com
Regression: Yes
Created an attachment (id=53882)
--> (https://bugzilla.kernel.org/attachment.cgi?id=53882)
Fixes a bug in futex_wait() that causes timeouts to be ignored
I noticed after starting a program from an xterm and trying to put it in the
background that it would not resume. In kernel/futex.c line 1889
restart->futex.flags needs FLAGS_HAS_TIMEOUT or the timeout gets ignored
after futex_wait() is interrupted by a signal. The code below triggers it
on my Slackware64 13.1 system (glibc-2.11.1).
#include <stdio.h>
#include <pthread.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
int main (void)
{
pthread_condattr_t ca;
pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cv;
struct timespec ts;
pid_t p;
int i;
if ( (p = fork()) != 0 )
{
printf("Child is running\n");
sleep(3);
kill(p, SIGSTOP);
printf("Child is stopped\n");
sleep(3);
kill(p, SIGCONT);
printf("Child should have resumed\n");
sleep(3);
kill(p, SIGINT);
return 0;
}
pthread_condattr_init(&ca);
pthread_condattr_setclock(&ca, CLOCK_MONOTONIC);
pthread_cond_init(&cv, &ca);
while(1)
{
clock_gettime(CLOCK_MONOTONIC, &ts);
printf("SLEEP: %lu\n", ts.tv_sec);
ts.tv_sec++;
pthread_cond_timedwait(&cv, &mut, &ts);
clock_gettime(CLOCK_MONOTONIC, &ts);
printf("WAKE: %lu\n", ts.tv_sec);
}
return 0;
}
--
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the Bugme-new
mailing list