Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4157987

(hpi) sysGetMilliTicks() will wraparound every 24 days

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Cannot Reproduce
    • Icon: P5 P5
    • None
    • 1.2.0
    • core-libs
    • generic
    • generic

      Method sysGetMilliTicks in solaris/hpi/src/system_md.c has possible problem:

      long
      sysGetMilliTicks()
      {
      struct timeval tv;

      (void) gettimeofday(&tv, (void *) 0);
      return((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
      }

      The multiply of tv_sec by 1000, this will wraparound every 24 days.
      (24 = (2**31)/(24*60*60*1000)) Places that measure an interval by calling
      sysGetMilliTicks() twice may get a very large positive value the first
      time and a very large negative value the second time, leading to all
      sorts of interesting results. Note that the wraparound occurs every 24
      days starting at some arbitrary time, not after the JVM has been up 24
      days.

      NOTE:
      It does not occur after a JVM has been up for 24 days. It occurs every
      24 days, based on the number of seconds since the EPOCH (Jan 1, 1970). So
      the wraparound can occur between any two calls! Of course once it occurs,
      it will not reoccur for another 24 days.

            Unassigned Unassigned
            jbenoit Jonathan Benoit (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: