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

Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 9
    • core-libs
    • None

    Description

      The implementations of VarHandle.getAndAdd/addAndGet for the byte[]/ByteBuffer views are incorrect if endian conversion is performed. The atomic addition is performed on the encoded augend.

      It just so happened that the associated tests use values that do not result in overflow over the byte ranges, hence a bad result was not observed.
       
      If the native endianess does not match that on the VarHandle then the atomic add should be performed in a CAS loop.

      Attachments

        Activity

          People

            psandoz Paul Sandoz
            psandoz Paul Sandoz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: