Created attachment 53882 [details]
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).
int main (void)
pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
struct timespec ts;
if ( (p = fork()) != 0 )
printf("Child is running\n");
printf("Child is stopped\n");
printf("Child should have resumed\n");
printf("SLEEP: %lu\n", ts.tv_sec);
pthread_cond_timedwait(&cv, &mut, &ts);
printf("WAKE: %lu\n", ts.tv_sec);
Please send the patch via email, not via bugzilla. Suitable recipients are
Thomas Gleixner <email@example.com>
Darren Hart <firstname.lastname@example.org>
Andrew Morton <email@example.com>
As it's a regression, please also include a Cc: <firstname.lastname@example.org> in the changelog.
Created attachment 54372 [details]
Set the flag during do_futex() along with the other flags
Updated patch attached. Sent to LKML for review.
After some discussion with Eric Dumazet, the final submitted patch simply ORs the FLAGS_HAS_TIMEOUT during setup of the restart block.
Created attachment 54392 [details]
V4, add flag during setup of restart block
A patch referencing this bug report has been merged in v2.6.39-rc4:
Author: Darren Hart <email@example.com>
Date: Thu Apr 14 15:41:57 2011 -0700
futex: Set FLAGS_HAS_TIMEOUT during futex_wait restart setup