Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-2523

BufferPool.releaseBuffer may release a buffer different than the head of the list

    XMLWordPrintableJSON

Details

    Description

      //BufferPool
        public void releaseBuffer(ByteBuffer byteBuffer) {
          // always remove from head of the list and append at last
          ByteBuffer buffer = bufferList.remove(0);
          // Ensure the buffer to be removed is always at the head of the list.
          Preconditions.checkArgument(buffer.equals(byteBuffer));
          buffer.clear();
          bufferList.add(buffer);
          Preconditions.checkArgument(currentBufferIndex >= 0);
          currentBufferIndex--;
        }
      

      In the code above, it expects buffer and byteBuffer are the same object, i.e. buffer == byteBuffer. However the precondition is checking buffer.equals(byteBuffer). Unfortunately, both buffer and byteBuffer have remaining() == 0 so that equals(..) returns true and the precondition does not catch the bug.

      Attachments

        1. a.patch
          3 kB
          Tsz-wo Sze

        Issue Links

          Activity

            People

              adoroszlai Attila Doroszlai
              szetszwo Tsz-wo Sze
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m