db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4088) DDMReader readBytes ArrayIndexOutOfBoundsException
Date Tue, 10 Mar 2009 18:10:51 GMT

    [ https://issues.apache.org/jira/browse/DERBY-4088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680563#action_12680563
] 

Knut Anders Hatlen commented on DERBY-4088:
-------------------------------------------

Thanks, I see the exception too now.

I haven't worked out all the details yet, but here's what I've found
so far:

readBytes() calls ensureBLayerDataInBuffer() which again calls
ensureALayerDataInBuffer(). ensureALayerDataInBuffer() ends up
enlarging the buffer and shifting the contents to the left so there is
enough space in the buffer (there is in fact enough space in the
buffer when that method returns) and fills the buffer with data.

After calling ensureALayerDataInBuffer(), ensureBLayerDataInBuffer()
detects that the DSS is shorter than the requested length, which means
that the data continues in a subsequent DSS. It calls
compressBLayerData() to remove DSS header bytes from the buffer so
that the buffer only contains the pure byte string and nothing
else. Since we only requested length bytes from the network, and some
of those bytes are header bytes, this means that the buffer contains
less than length bytes after we have "compressed" the buffer. This is
what's eventually causing the exception when we try to copy more bytes
from the buffer than we actually have available.

I think one possible fix is to make compressBLayerData() fill the
buffer with the missing bytes from the continuation DSS.

(One other thing to investigate is why the client splits the data into
smaller chunks when it is small enough to fit in a single DSS. It
sounds suboptimal.)

> DDMReader readBytes ArrayIndexOutOfBoundsException
> --------------------------------------------------
>
>                 Key: DERBY-4088
>                 URL: https://issues.apache.org/jira/browse/DERBY-4088
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Server
>    Affects Versions: 10.4.2.0
>         Environment: CentOS 5, java 1.6.0_11
>            Reporter: Urban Widmark
>         Attachments: derby-ddm.patch, DerbyBug.java
>
>
> DDMReader.readBytes(int length) checks the length vs DssConstants.MAX_DSS_LENGTH, but
ignores the fact that the buffer position "pos" might not be 0. If pos is non-zero then the
pos + length can be larger than the size of "buffer" causing an ArrayIndexOutOfBoundsException.
> For me this happened when sending a BLOB that was 32766 bytes long. The value of pos
was 2 in that method.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message