apache/uima-uimaj

Unable to deserialize CAS if last element on the heap is an empty array

reckart opened this issue · 0 comments

Describe the bug
There is a very rare bug in deserializing a CAS when the last element on the heap is an empty array and the heap and there is no additional space on the heap after that element.

To Reproduce
TBH, I have no idea how to really reproduce this. But here is what happens:

BinaryCasSerDes.java

     heapIndex=254
     heap.heap.length=256
----
      if (type.isArray()) {
        final int len = heap.heap[heapIndex + arrayLengthFeatOffset]; // We get the length of the array -> 0
        final int bhi = heap.heap[heapIndex + arrayContentOffset]; // We get the pointer(?) to the start of the array 254+2 -> CRASH

The code crashes with an IndexOutOfBoundsException because heapIndex + arrayContentOffset >= heap.heap.length. However, we do not really need bhi because the array is empty and thus we won't read its contents anyway.

Expected behavior
If the array is empty, skip bhi and related core entirely.

Please complete the following information:

  • Version: 3.4.0