Bug 47131

GemStone/S 64 Bit

3.3.6, 3.3.5, 3.3.4, 3.3.3, 3.3.2, 3.3.1, 3.3

3.4, 3.3.7

Out of range #at: into very large ByteArray triggers corrupt object error

With a large ByteArray (a ByteArray with a size > 16272), if an argument to at: or at:put: is greater than the size of the ByteArray, it triggers a corrupt object error rather than the expected OffsetError.  A corrupt object error prevents commit.

Workaround

The following filein patches the ByteArray at: method.

category:  'Patch bug 47131'
method: ByteArray
_at: anIndex

"Original ByteArray>>at: method -- demoted to provide
 index range check before calling the primitive

 Returns the value of an indexed variable in the receiver.
 The argument anIndex must not be larger than the size of the
 receiver, and must not be less than 1.

 Generates an error if anIndex is not a SmallInteger or is out of
 bounds, or if the receiver is not indexable."



(anIndex _isInteger)
  ifTrue: [^ self _errorIndexOutOfRange: anIndex]
  ifFalse: [^ self _errorNonIntegerIndex: anIndex].
self _primitiveFailed: #at: args: { anIndex } .
self _uncontinuableError
% 

category:  'Patch bug 47131'
method: ByteArray
at: anIndex

"Replacement ByteArray>>at: method -- original moved to ByteArray>>_at: "

(anIndex > self size) ifTrue: [ ^ self _errorIndexOutOfRange: anIndex ].
^ self _at: anIndex
%


Last updated: 5/18/18