Subject: Re: bug#7317: Bug in SLEEP command

From: Pádraig Brady <[email-masked]>
Date: Tue, 02 Nov 2010 16:59:23 +0000

On 02/11/10 15:46, Андрей Передрий wrote:
> 
> Hello guys!
> 
> I found a bug in 'sleep' command.
> Please see below:
> 
> # date
> Tue Oct  5 14:12:11 EEST 2010
> [root@gate ~]# sleep 36500d ; date
> Sat Oct 30 10:38:44 EEST 2010
> [root@gate ~]#
> 
> As you can see - 'sleep' was terminated by himself after 24 days, 20 hours, 26 minutes and 33 seconds.
> 24*24*3600 + 20*3600 + 26*60 + 33 = 2073600 + 72000 + 1560 + 33 = 2147193 seconds
> It seems like overflow.
> coreutils 6.10-6
> Debian 5.0.6  

eek!
That's lenny right, with kernel 2.6.32 or so.

POSIX says that we should support 2147483647 seconds at least.
We could make multiple calls to xnanosleep if the param is
greater than that, but do we really need to support > 68 years.
Currently we silently truncate to this limit.

Anyway could you send the output of: strace sleep 36500d

On 64 bit lenny here I get: nanosleep({3153600000, 0},
On 32 bit Fedora 11 I get:  nanosleep({2147483647, 999999999}

If you get a large value being passed down,
then it suggests an issue with glibc/kernel?

cheers,
Pádraig.