Return-Path: X-Original-To: apmail-directmemory-dev-archive@www.apache.org Delivered-To: apmail-directmemory-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C3F6C10F38 for ; Wed, 15 Jan 2014 04:48:29 +0000 (UTC) Received: (qmail 48103 invoked by uid 500); 15 Jan 2014 04:48:29 -0000 Delivered-To: apmail-directmemory-dev-archive@directmemory.apache.org Received: (qmail 48028 invoked by uid 500); 15 Jan 2014 04:48:22 -0000 Mailing-List: contact dev-help@directmemory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directmemory.apache.org Delivered-To: mailing list dev@directmemory.apache.org Received: (qmail 48018 invoked by uid 500); 15 Jan 2014 04:48:20 -0000 Delivered-To: apmail-incubator-directmemory-dev@incubator.apache.org Received: (qmail 48015 invoked by uid 99); 15 Jan 2014 04:48:19 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jan 2014 04:48:19 +0000 Date: Wed, 15 Jan 2014 04:48:19 +0000 (UTC) From: "Chetan Mehrotra (JIRA)" To: directmemory-dev@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (DIRECTMEMORY-137) Concurrent access to MemoryBuffer leads to BufferUnderflowException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Chetan Mehrotra created DIRECTMEMORY-137: -------------------------------------------- Summary: Concurrent access to MemoryBuffer leads to BufferUnderflowException Key: DIRECTMEMORY-137 URL: https://issues.apache.org/jira/browse/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 @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 -- This message was sent by Atlassian JIRA (v6.1.5#6160)