VirtualBox

Ticket #4505 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

clock_gettime() returning incorrect result

Reported by: mr_mop Owned by:
Priority: major 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

VBox1.log Download (43.4 KB) - added by mr_mop 5 years ago.
Vbox.log from boot until after running the test application.

Change History

Changed 5 years ago by mr_mop

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

comment:1 Changed 5 years ago by sandervl73

Try again with 3.0.2.

comment:2 Changed 5 years ago by sandervl73

  • Summary changed from clock_gettime() returning incorrect result. to clock_gettime() returning incorrect result. -> retry with 3.0.2

comment:3 Changed 5 years ago by mr_mop

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

comment:4 Changed 5 years ago by frank

  • Version changed from VirtualBox 3.0.0 to VirtualBox 3.0.2
  • Summary changed from clock_gettime() returning incorrect result. -> retry with 3.0.2 to clock_gettime() returning incorrect result

comment:5 Changed 5 years ago by frank

  • Status changed from new to closed
  • Resolution set to fixed

Should be finally fixed with VBox 3.0.6.

comment:6 Changed 4 years ago by oneeyed

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 Changed 4 years ago by mr_mop

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 Changed 4 years ago by frank

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

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use