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

[Linux] Park(millis) can use the wrong clock if pthread_condattr_setclock failed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8
    • hotspot
    • b109
    • 8
    • linux

      In JDK-6900441 we fixed the park implementation on Linux to use CLOCK_MONOTONIC using pthread_condattr_setclock, which is now required to be available on all supported Linux platforms. However we also allowed for it to fail at runtime:

      + // Only set the clock if CLOCK_MONOTONIC is available
      + if (Linux::supports_monotonic_clock()) {
      + if ((status = pthread_condattr_setclock(_condattr, CLOCK_MONOTONIC)) != 0) {
      + if (status == EINVAL) {
      + warning("Unable to use monotonic clock with relative timed-waits" \
      + " - changes to the time-of-day clock may have adverse affects");
      + } else {
      + fatal(err_msg("pthread_condattr_setclock: %s", strerror(status)));
      + }
      + }
      + }

      If we do hit the EINVAL case we simply print the warning, but computeAbsTime and unpackTime will still calculate relative timeouts using CLOCK_MONOTONIC, which is wrong if the pthread_cond_timedwait is actually going to use CLOCK_REALTIME.

            Unassigned Unassigned
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: