Issue 30255: test_xml_etree: python: Objects/sliceobject.c:176: _PySlice_AdjustIndices: Assertion `step >= -PY_SSIZE_T_MAX' failed. (original) (raw)

Created on 2017-05-03 11:06 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1429 merged vstinner,2017-05-03 12:25
Messages (8)
msg292888 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 11:06
./python -m test -v test_xml_etree ... test_getslice_negative_steps (test.test_xml_etree.ElementSlicingTest) ... python: Objects/sliceobject.c:176: _PySlice_AdjustIndices: Assertion `step >= -PY_SSIZE_T_MAX' failed. ... Traceback (most recent call first): File "/home/haypo/prog/python/2.7/Lib/xml/etree/ElementTree.py", line 266, in __getitem__ return self._children[index] File "/home/haypo/prog/python/2.7/Lib/test/test_xml_etree.py", line 2305, in test_getslice_negative_steps self.assertEqual(self._elem_tags(e[3::-sys.maxsize-1]), ['a3']) See issues: bpo-30074, bpo-27867.
msg292894 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 12:26
Attached PR fixes test_xml_etree.
msg292898 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-03 12:51
Thank you Victor for noticing and fixing this crash!
msg292901 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 14:00
New changeset f6a3133972378205baaa6a854d46170d04a2db67 by Victor Stinner in branch '2.7': bpo-30255: Clip step in _PySlice_Unpack() (#1429) https://github.com/python/cpython/commit/f6a3133972378205baaa6a854d46170d04a2db67
msg292902 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 14:03
I pushed the change to try to fix buildbots, but I'm not sure that it's complete. The change announces "... clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] ...", but there is no explicit to clip the maximum to PY_SSIZE_T_MAX. Maybe there is a bug on this side too! The code should be reviewed one more time.
msg292903 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 14:05
> Thank you Victor for noticing and fixing this crash! Something is *very* strange: we have +20 buildbots, but I didn't see this assertion failure on any buildbot. Instead, I noticed that regrtest runs less tests than announced: see issue #30254. It's very strange because I expect either a crash: regrtest stops with no more output, or a report of the crash. But no, regrtest displays the summary as everything was fine...
msg293036 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-05 01:49
> It's very strange because I expect either a crash: regrtest stops with no more output, or a report of the crash. But no, regrtest displays the summary as everything was fine... It was a bug in regrtest: now fixed by bpo-30258.
msg293075 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-05 08:26
> The change announces "... clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] ...", but there is no explicit to clip the maximum to PY_SSIZE_T_MAX. Maybe there is a bug on this side too! The code should be reviewed one more time. Ok, I checked: _PySlice_Unpack() uses _PyEval_SliceIndex() to convert the step Python object into a C Py_ssize_t, so the code is already correct: it does "clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX]" as announced ;-) I close the issue. Thanks Serhiy for your work on fixing corner cases related to slices ;-)
History
Date User Action Args
2022-04-11 14:58:46 admin set github: 74441
2017-05-05 08:26:40 vstinner set status: open -> closedresolution: fixedmessages: + stage: resolved
2017-05-05 01:49:59 vstinner set messages: +
2017-05-03 14:05:20 vstinner set messages: +
2017-05-03 14:03:41 vstinner set messages: +
2017-05-03 14:00:14 vstinner set messages: +
2017-05-03 12:51:04 serhiy.storchaka set messages: +
2017-05-03 12:26:51 vstinner set nosy: + xiang.zhangmessages: +
2017-05-03 12:25:32 vstinner set pull_requests: + <pull%5Frequest1534>
2017-05-03 12:10:21 vstinner set messages: -
2017-05-03 12:08:48 vstinner set messages: +
2017-05-03 11:06:38 vstinner create