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

From: Андрей Передрий <[email-masked]>
Date: Tue, 02 Nov 2010 19:39:16 +0200

> > 
> > Hello guys!
> > 
> > I found a bug in 'sleep' command.
> 
> > 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 
> 
> Is your system 32-bit or 64-bit? It makes a difference in determining
> whether there is a bug in the OS sleep primitives (for example, we know
> that 64-bit Linux has a bug where nanosleep with an extremely large
> value will cause the kernel to overflow and sleep for the wrong amount
> of time, but coreutils has workarounds in place for that).
> 
> Also, consider upgrading; the latest stable coreutils release is 8.6,
> and there have been some gnulib fixes in the meantime to improve the
> robustness of the sleep workarounds in use by coreutils.
> 

I am sorry!
Correct platform is: 
RHEL & Centos 4.6 & 4.8
 2.6.9-89.0.23.ELsmp

 strace sleep 36500d

execve("/bin/sleep", ["sleep", "36500d"], [/* 20 vars */]) = 0
uname({sys="Linux", node="gate.shipregistr.kiev.ua", ...}) = 0
brk(0)                                  = 0x9541000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=20328, ...}) = 0
old_mmap(NULL, 20328, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f56000
close(3)                                = 0
open("/lib/tls/libm.so.6", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\0003\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=212236, ...}) = 0
old_mmap(NULL, 139424, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x54d000
old_mmap(0x56e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x20000) = 0x56e000
close(3)                                = 0
open("/lib/tls/librt.so.1", O_RDONLY)   = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320 \0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=48788, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f55000
old_mmap(NULL, 81656, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x28b000
old_mmap(0x293000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x293000
old_mmap(0x295000, 40696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x295000
close(3)                                = 0
open("/lib/tls/libc.so.6", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\200O\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1544948, ...}) = 0
old_mmap(NULL, 1244380, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x111000
old_mmap(0x23b000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x129000) = 0x23b000
old_mmap(0x23f000, 7388, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x23f000
close(3)                                = 0
open("/lib/tls/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0PH\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=105912, ...}) = 0
old_mmap(NULL, 70108, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x650000
old_mmap(0x65e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd000) = 0x65e000
old_mmap(0x660000, 4572, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x660000
close(3)                                = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f54000
mprotect(0x65e000, 4096, PROT_READ)     = 0
mprotect(0x23b000, 8192, PROT_READ)     = 0
mprotect(0x293000, 4096, PROT_READ)     = 0
mprotect(0x56e000, 4096, PROT_READ)     = 0
mprotect(0xfbe000, 4096, PROT_READ)     = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7f546c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0xb7f56000, 20328)               = 0
set_tid_address(0xb7f54708)             = 19936
rt_sigaction(SIGRTMIN, {0x654380, [], SA_RESTORER|SA_SIGINFO, 0x65bc90}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x6543f0, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x65bc90}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0
_sysctl({{CTL_KERN, KERN_VERSION}, 2, 0xbfe5e27c, 35, (nil), 0}) = 0
brk(0)                                  = 0x9541000
brk(0x9562000)                          = 0x9562000
clock_gettime(CLOCK_REALTIME, {1288719488, 927427000}) = 0
nanosleep({2147483647, 999999999},  

--
A.P.