[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
nanosleep truncated on 64 bit Linux by 292 billion years
From: |
Pádraig Brady |
Subject: |
nanosleep truncated on 64 bit Linux by 292 billion years |
Date: |
Mon, 27 Oct 2014 04:01:44 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
I noticed that nanosleep() on 64 bit, "only" supports 292 years,
rather than the full potential 292 billion years with 64 bit time_t, due to:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/time.h?id=refs/tags/v3.16#n87
Attached is a program from Paul Eggert that illustrates the bug.
Running this program on a buggy host outputs something like this:
Setting alarm for 1 second from now ...
Sleeping for 9223372036854775807.999999999 seconds...
After alarm sent off, remaining time is 9223357678.462306617 seconds;
i.e., nanosleep claimed that it slept for about 293079448610.606445 years.
Gnulib-using applications have a workaround for this bug, but a workaround
shouldn't be necessary. For what it's worth, the bug is fixed in Solaris 11
(x86-64),
though it's present in Solaris 10 (64-bit sparc).
thanks,
Pádraig.
nanosleep-bug.c
Description: Text document
- nanosleep truncated on 64 bit Linux by 292 billion years,
Pádraig Brady <=