#4505 closed defect (fixed)
clock_gettime() returning incorrect result
Reported by: | Mr Mop | Owned by: | |
---|---|---|---|
Component: | other | Version: | VirtualBox 3.0.2 |
Keywords: | Cc: | ||
Guest type: | Linux | Host type: | Windows |
Description
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 <stdio.h> #include <stdlib.h> #include <time.h> 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.
Attachments (1)
Change History (9)
by , 16 years ago
comment:2 by , 16 years ago
Summary: | clock_gettime() returning incorrect result. → clock_gettime() returning incorrect result. -> retry with 3.0.2 |
---|
comment:4 by , 16 years ago
Summary: | clock_gettime() returning incorrect result. -> retry with 3.0.2 → clock_gettime() returning incorrect result |
---|---|
Version: | VirtualBox 3.0.0 → VirtualBox 3.0.2 |
comment:5 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Should be finally fixed with VBox 3.0.6.
comment:6 by , 15 years ago
This looks awfully similar to #6318 which is still present in 3.1.4. Is it supposed to be fixed in this version too?
comment:7 by , 15 years ago
Yes, I suspect that it is the same issue. The test program I attached above seems to be masking the problem and so appears fixed. If the printf()s used to display the current times is removed, and the for loop converted to an infinite loop, the problem is seen. With the printf()s and the loop limit, the problem is not seen.
I'd say this is not fixed, but as your bug is newer, and about the same issue, I'll leave this one as closed. The issue can then be tracked in your new bug.
Vbox.log from boot until after running the test application.