VirtualBox

Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#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)

VBox1.log (43.4 KB ) - added by Mr Mop 15 years ago.
Vbox.log from boot until after running the test application.

Download all attachments as: .zip

Change History (9)

by Mr Mop, 15 years ago

Attachment: VBox1.log added

Vbox.log from boot until after running the test application.

comment:1 by Sander van Leeuwen, 15 years ago

Try again with 3.0.2.

comment:2 by Sander van Leeuwen, 15 years ago

Summary: clock_gettime() returning incorrect result.clock_gettime() returning incorrect result. -> retry with 3.0.2

comment:3 by Mr Mop, 15 years ago

Just tried this on 3.0.2, and still see the same result.

comment:4 by Frank Mehnert, 15 years ago

Summary: clock_gettime() returning incorrect result. -> retry with 3.0.2clock_gettime() returning incorrect result
Version: VirtualBox 3.0.0VirtualBox 3.0.2

comment:5 by Frank Mehnert, 15 years ago

Resolution: fixed
Status: newclosed

Should be finally fixed with VBox 3.0.6.

comment:6 by Samuel Tardieu, 14 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 Mr Mop, 14 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.

comment:8 by Frank Mehnert, 14 years ago

Please attach a VBox.log file of such a session.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use