[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sleep, nanosleep test failures
From: |
Jim Meyering |
Subject: |
Re: sleep, nanosleep test failures |
Date: |
Fri, 12 Nov 2010 12:26:20 +0100 |
Bruno Haible wrote:
> On a stock Linux/x86 machine I observe these test failures:
>
> test-nanosleep.c:78: assertion failed
> FAIL: test-nanosleep
> test-sleep.c:53: assertion failed
> FAIL: test-sleep
>
> It's a "Red Hat Enterprise Linux ES release 4 (Nahant Update 8)" machine
> with Linux 2.6.9 kernel and glibc 2.3.4.
>
> The reason is that when sleep() is asked to sleep for 49 days and interrupted
> after 1 second, it returns an "unslept amount" of 24.85 days. This is similar
> to the Cygwin 1.5.x behaviour, for which we already have a workaround.
>
> ltrace execution:
>
> signal(14, 0x8048740) = NULL
> alarm(1) = 0
> sleep(4233600 <unfinished ...>
> --- SIGALRM (Alarm clock) ---
> <... sleep resumed> ) = 2147156
>
> strace execution:
>
> rt_sigaction(SIGALRM, {0x8048740, [ALRM], SA_RESTORER|SA_RESTART,
> 0x5ee9b8}, {SIG_DFL}, 8) = 0
> alarm(1) = 0
> rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
> rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
> rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> nanosleep({4233600, 0}, 0xbfe8a254) = ? ERESTART_RESTARTBLOCK (To be
> restarted)
> --- SIGALRM (Alarm clock) @ 0 (0) ---
> sigreturn() = ? (mask now [])
>
> Looking at the implementation of sleep() in glibc, the bug must be really in
> the kernel.
>
> Jim, is this OK to commit? It fixes the issue.
>
>
> 2010-11-12 Bruno Haible <address@hidden>
>
> sleep, nanosleep: Work around Linux 2.6.9 nanosleep bug.
> * lib/sleep.c (rpl_sleep): Split in chunks no larger than 24 days.
> * lib/nanosleep.c (nanosleep): Likewise.
Nice! I'm glad you found an efficient test for that.
You're welcome to push your fix.
Thank you.