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

Atomic::cmpxchg for jbyte is missing a fence on initial failure

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b135

      Description

      The generalized jbyte version has to perform a real cmpxchg on a full word (jint) so it has to isolate the correct byte within the word. We have a loop:

       while (cur_as_bytes[offset] == compare_value) {
          jint res = cmpxchg(new_val, dest_int, cur);
          if (res == cur) break;
          cur = res;
          new_val = cur;
          new_val_as_bytes[offset] = exchange_value;
        }

      but if we fail the initial comparison there is no fence, as required by the semantics for cmpxchg as defined in atomic.hpp.

      This was discovered during the review of JDK-8155949.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: