This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix and test overflow behavior in the C version of heapq
Type: behavior Stage: needs patch
Components: Extension Modules Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: python-dev, rhettinger, tim.peters
Priority: normal Keywords: patch

Created on 2014-04-28 17:59 by rhettinger, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_overflow.diff rhettinger, 2014-04-29 08:36 review
Messages (5)
msg217389 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-04-28 17:59
The Py_ssizet indexes can overflow the "childpos" variable:

    childpos = 2*pos + 1;    /* leftmost child position  */
    while (childpos < endpos) ...


http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
msg217493 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-04-29 08:36
Attaching a fix.  I can't think of a way to test this without an array of sys.maxsize.
msg217555 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2014-04-29 21:18
I don't see a way to test it either, but it's easy enough to prove it's correct ;-)  That is, looks good to me!
msg217835 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-05-03 22:26
New changeset 725cb631699a by Raymond Hettinger in branch '3.4':
Issue 21375:  Fix possible Py_ssizet overflow in heapq.
http://hg.python.org/cpython/rev/725cb631699a
msg217836 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-05-03 22:30
New changeset b768d41dec0a by Raymond Hettinger in branch '2.7':
Issue 21375:  Fix possible Py_ssizet overflow in heapq.
http://hg.python.org/cpython/rev/b768d41dec0a
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65574
2014-05-03 22:45:52rhettingersetstatus: open -> closed
resolution: fixed
2014-05-03 22:30:17python-devsetmessages: + msg217836
2014-05-03 22:26:31python-devsetnosy: + python-dev
messages: + msg217835
2014-04-29 21:18:41tim.peterssetnosy: + tim.peters
messages: + msg217555
2014-04-29 08:36:34rhettingersetfiles: + fix_overflow.diff
keywords: + patch
messages: + msg217493
2014-04-28 17:59:54rhettingercreate