Message12642

Author jeff.allen
Recipients jeff.allen
Date 2019-08-27.22:58:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566946709.13.0.667315258665.issue2796@roundup.psfhosted.org>
In-reply-to
Content
I noticed this failure in test_bytes, running with 2.7.2a1 standalone JAR:

======================================================================
ERROR: test_repeat (__main__.ByteArrayTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Jeff\Documents\Jython\272b-trial\Lib\test\test_bytes.py", line 233, in test_repeat
    lambda: b * sys.maxsize)
  File "C:\Users\Jeff\Documents\Jython\272b-trial\kit\jython-standalone.jar\Lib\unittest\case.py", line 476, in assertRaises
    callableObj(*args, **kwargs)
  File "C:\Users\Jeff\Documents\Jython\272b-trial\Lib\test\test_bytes.py", line 233, in <lambda>
    lambda: b * sys.maxsize)
ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: arraycopy: last destination index 2147483646 out of bounds for byte[2147483645]

----------------------------------------------------------------------

Note that the apparent array size 2147483645 is the result of b*sys.maxsize, where len(b) is 3, and a lossy long to int conversion, taking place in org.python.core.BaseBytes.repeatImpl(int). We should be comparing first with sys.maxsize.

In our tests this is usually masked by a MemoryError, but for some reason not in standalone.

Also look elsewhere in BaseBytes and PyByteArray for other places we allocate an array without checking the size.
History
Date User Action Args
2019-08-27 22:58:29jeff.allensetrecipients: + jeff.allen
2019-08-27 22:58:29jeff.allensetmessageid: <1566946709.13.0.667315258665.issue2796@roundup.psfhosted.org>
2019-08-27 22:58:29jeff.allenlinkissue2796 messages
2019-08-27 22:58:28jeff.allencreate