directmemory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chetan Mehrotra (JIRA)" <>
Subject [jira] [Created] (DIRECTMEMORY-137) Concurrent access to MemoryBuffer leads to BufferUnderflowException
Date Wed, 15 Jan 2014 04:48:19 GMT
Chetan Mehrotra created DIRECTMEMORY-137:

             Summary: Concurrent access to MemoryBuffer leads to BufferUnderflowException
                 Key: DIRECTMEMORY-137
             Project: Apache DirectMemory
          Issue Type: Bug
          Components: core
    Affects Versions: 0.2
            Reporter: Chetan Mehrotra

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

    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


This message was sent by Atlassian JIRA

View raw message