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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 8
    • Fix Version/s: None
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Introduced In Build:
      b109
    • Introduced In Version:
      8
    • OS:
      linux

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: