You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-issues@hadoop.apache.org by "Tsz-wo Sze (Jira)" <ji...@apache.org> on 2019/11/18 00:09:00 UTC
[jira] [Updated] (HDDS-2523) BufferPool.releaseBuffer may release a
buffer different than the head of the list
[ https://issues.apache.org/jira/browse/HDDS-2523?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tsz-wo Sze updated HDDS-2523:
-----------------------------
Description:
{code}
//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--;
}
{code}
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, the both buffer have remaining() == 0 so that equals(..) returns true and the precondition does not catch the bug.
was:
{code}
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--;
}
{code}
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, the both buffer have remaining() == 0 so that equals(..) returns true and the precondition does not catch the bug.
> BufferPool.releaseBuffer may release a buffer different than the head of the list
> ---------------------------------------------------------------------------------
>
> Key: HDDS-2523
> URL: https://issues.apache.org/jira/browse/HDDS-2523
> Project: Hadoop Distributed Data Store
> Issue Type: Bug
> Reporter: Tsz-wo Sze
> Priority: Major
>
> {code}
> //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--;
> }
> {code}
> 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, the both buffer have remaining() == 0 so that equals(..) returns true and the precondition does not catch the bug.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org