Uploaded image for project: 'Apache DirectMemory'
  1. Apache DirectMemory
  2. DIRECTMEMORY-137

Concurrent access to MemoryBuffer leads to BufferUnderflowException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.2
    • None
    • core
    • None

    Description

      When same MemoryBuffer is accessed by multiple thread concurrently then it can lead to BufferUnderflowException.

      MemoryManagerService.retrieve method performs following steps

      1. Get MemoryBuffer associated with the Pointer
      2. Set its readerIndex to 0
      3. Call readBytes. Which for NioMemoryBuffer invokes following code

      @Override
      public int readBytes( byte[] bytes, int offset, int length )

      { byteBuffer.get( bytes, offset, length ); readerIndex += length; return length; }

      So if multiple thread invoke retrieve with same Pointer then readerIndex might be set to wrong value leading to BufferUnderflowException

      Refer to [1] for details

      [1] http://markmail.org/thread/yvevhzddta2fyal6

      Attachments

        1. DIRECTMEMORY-137.patch
          3 kB
          Chetan Mehrotra

        Activity

          People

            Unassigned Unassigned
            chetanm Chetan Mehrotra
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: