Issue2324
Created on 2015-04-13.19:07:54 by jmadden, last changed 2015-04-23.03:56:38 by zyasoft.
msg9810 (view) |
Author: Jason Madden (jmadden) |
Date: 2015-04-13.19:07:54 |
|
This shows up in testing ZODB under Jython. ZODB creates a StringIO object and repeatedly uses it to pickle objects, resetting it each time. Given the write sequence of calls, this results in a StringIndexOutOfBoundsException.
>>> from cStringIO import StringIO
>>> before = 'cpersistent.mapping\nPersistentMapping\nq\x00.}q\x01U\x04dataq\x02}q\x03U\x04testq\x04(U\x08\x00\x00\x00\x00\x00\x00\x00\x01q\x05h\x00tq\x06Qss.'
>>> sio.write(before)
>>> sio.truncate()
>>> sio.seek(0)
strs = ['cpersistent.mapping\nPersistentMapping\n',
... 'q\x00',
... '.',
... '}',
... 'q\x01',
... 'U\x04data',
... 'q\x02',
... '}',
... 'q\x03',
... '(',
... 'K\x00',
... '(',
... 'U\x08\x00\x00\x00\x00\x00\x00\x00\x02',
... 'q\x04',
... 'h\x00',
... 't',
... 'q\x05',
... 'Q',
... 'K\x01',
... '(',
... 'U\x08\x00\x00\x00\x00\x00\x00\x00\x03']
>>> for i in strs:
... sio.write(i)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
at java.lang.AbstractStringBuilder.replace(AbstractStringBuilder.java:828)
at java.lang.StringBuilder.replace(StringBuilder.java:262)
at org.python.modules.cStringIO$StringIO.write(cStringIO.java:375)
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
java.lang.StringIndexOutOfBoundsException: java.lang.StringIndexOutOfBoundsException: start > end
The exception happens on the very last string in the list.
|
msg9817 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-04-13.21:51:21 |
|
Wow, ZODB? That's crazy talk on Jython! ;)
I will take a look and see if we can fix quickly, since that would be very cool.
|
msg9819 (view) |
Author: Jason Madden (jmadden) |
Date: 2015-04-13.21:55:42 |
|
ZODB does have a workaround in using `io.BytesIO`, so it's not super-urgent from that perspective (although I think StringIO is probably faster?). It does seem like a general bug though that anyone could hit.
|
msg9830 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-04-14.03:56:03 |
|
So it's a problem in using seek. and how that interacts with a previous allocation of bytes in terms of determining additional capacity.
|
msg9839 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-04-14.15:27:58 |
|
Easy fix - the replacement, then subsequent append of the StringBuilder is just not computing correct parameters. Fix forthcoming.
|
msg9858 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-04-15.15:11:20 |
|
Fixed as of https://hg.python.org/jython/rev/ce136d0b598f
|
msg9860 (view) |
Author: Jason Madden (jmadden) |
Date: 2015-04-15.15:54:03 |
|
Thank you. I can confirm that ce136d0b598f does fix the ZODB tests.
|
|
Date |
User |
Action |
Args |
2015-04-23 03:56:38 | zyasoft | set | status: pending -> closed |
2015-04-15 15:54:03 | jmadden | set | messages:
+ msg9860 |
2015-04-15 15:11:21 | zyasoft | set | status: open -> pending resolution: accepted -> fixed messages:
+ msg9858 |
2015-04-14 23:33:46 | zyasoft | set | priority: high -> urgent milestone: Jython 2.7.0 |
2015-04-14 15:27:58 | zyasoft | set | messages:
+ msg9839 |
2015-04-14 03:56:03 | zyasoft | set | messages:
+ msg9830 |
2015-04-13 21:55:43 | jmadden | set | messages:
+ msg9819 |
2015-04-13 21:51:21 | zyasoft | set | priority: high assignee: zyasoft resolution: accepted messages:
+ msg9817 nosy:
+ zyasoft |
2015-04-13 19:07:54 | jmadden | create | |
|