[ 
https://issues.apache.org/jira/browse/ARTEMIS-4340?focusedWorklogId=868948&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-868948
 ]

ASF GitHub Bot logged work on ARTEMIS-4340:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Jul/23 16:42
            Start Date: 03/Jul/23 16:42
    Worklog Time Spent: 10m 
      Work Description: gemmellr opened a new pull request, #4533:
URL: https://github.com/apache/activemq-artemis/pull/4533

   The report for ARTEMIS-4340 was raised about ByteUtil.uncheckedZeros 
throwing IndexOutOfBoundsException. Though some of ByteUtil's behaviour can 
perhaps be questioned around its consistency with different buffer types, in 
this case the problem ultimately starts earlier in the call tree with 
org.apache.activemq.artemis.core.io.util.ThreadLocalByteBufferPool.borrow(int, 
boolean) passing it invalid arguments. It passes in a buffer for zeroing, with 
its limit still set below the requested size to be zero'd, leading to the 
IndexOutOfBoundsException in this case when tryign to write beyond the limit. 
The reason this seemingly long-standing bug has perhaps not been hit so far is 
that it occurs in a less typical case where the buffer isnt direct, but also 
doesnt have an array.
   
   ThreadLocalByteBufferPool should clear position+limit before zeroing the 
buffer.




Issue Time Tracking
-------------------

            Worklog Id:     (was: 868948)
    Remaining Estimate: 0h
            Time Spent: 10m

> ByteUtil.uncheckedZeros throws IndexOutOfBoundsException in else condition
> --------------------------------------------------------------------------
>
>                 Key: ARTEMIS-4340
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4340
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: ActiveMQ-Artemis-Native
>    Affects Versions: 2.22.0
>         Environment: Windows 10, Linux
>            Reporter: David Hoffer
>            Assignee: Clebert Suconic
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> In artemis-commons:
> ByteUtil.uncheckedZeros throws IndexOutOfBoundsException in the else part of 
> the method.
> The code in the else part is looping through number of bytes specified by 
> bytes input parameter which is often provided by buffer.capacity(), but then 
> the code at 
> buffer.put(i + offset, zero) where buffer is of DirectByteBuffer type calls 
> checkIndex(int i) and it throws if i is >= limit.
> But limit is not the same as capacity in a Buffer.  In our case capacity is 
> 4096 and limit is 16 so method always throws IndexOutOfBoundsException if the 
> else case is executed as soon as i ==16.
> This code is called when Artemis is launched and it validates/creates the 
> various bindings files.  This causes Artemis to fail to load properly.
> Note I believe all versions of artemis-commons has this bug but I currently 
> am testing with 2.22.0.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to