id,summary,reporter,owner,description,type,status,priority,component,version,resolution,keywords,cc,guest,host
4505,clock_gettime() returning incorrect result,mr_mop,,"I am running Ubuntu 9.04 under VirtualBox 3.0.0.
I have found a problem that is seen with clock_gettime()
On some occasions, the result of clock_gettime() will go backwards.
It can be shown the this code:
{{{
#include
#include
#include
int main (int argc,char *argv[])
{
struct timespec t;
struct timespec ot;
int i = 0;
for(i = 0;i < 100000;i++)
{
clock_gettime(CLOCK_MONOTONIC,&ot);
clock_gettime(CLOCK_MONOTONIC,&t);
printf(""%d time 1 secs = %lld\n"",i,(long long int)ot.tv_sec);
printf(""%d time 2 secs = %lld\n"",i,(long long int)t.tv_sec);
printf(""%d time 1 nsecs = %lld\n"",i,(long long int)ot.tv_nsec);
printf(""%d time 2 nsecs = %lld\n"",i,(long long int)t.tv_nsec);
if(ot.tv_sec > t.tv_sec)
{
printf(""**** Old sec > new sec ****\n"");
exit(-1);
}
if(ot.tv_nsec > t.tv_nsec)
{
printf(""**** Old nsec > new ssec ****\n"");
exit(-1);
}
}
}
return 0;
}}}
I have tried this on other VM clients with the same version of Ubuntu, and it works fine.
There is no cleverness to detect a wrap around from 999999999 nsecs to 0 nsecs, but the failure will occur before this happens.",defect,closed,major,other,VirtualBox 3.0.2,fixed,,,Linux,Windows