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: Invalid access in combinations_with_replacement()
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Arfrever, python-dev, rhettinger, serhiy.storchaka, skrah, vstinner
Priority: normal Keywords: patch

Created on 2015-07-27 11:19 by skrah, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
itertools_invalid_access.diff skrah, 2015-07-27 11:19 review
Messages (5)
msg247460 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2015-07-27 11:19
There's a corner case in cwr_next(), where the pool size is zero
but pool[0] is accessed:


from itertools import *
it = combinations_with_replacement([], 0)
next(it)


Patch attached.
msg247509 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-07-28 09:08
New changeset fd3fb122c5ff by Raymond Hettinger in branch '3.4':
Issue #24735: Fix invalid memory access in combinations_with_replacement()
https://hg.python.org/cpython/rev/fd3fb122c5ff
msg247512 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-07-28 09:31
Can someone please write an unit test to avoid regressions in the future?
msg247513 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2015-07-28 10:32
Victor, there was no actual crash, just a potential one. In
terms of the observable runtime behavior the code behaved
correctly.

I would not know what to test for, unless we set up a buildbot
running Valgrind (which is impracticable for a number of reasons).
msg247514 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-07-28 10:34
Oh I see. Ok, since it's a corner case, I'm fine with no unit test. Thanks for the report Stefan, and thanks for the fix Raymond ;-)
History
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 68923
2015-08-17 05:22:28Arfreversetnosy: + Arfrever
2015-07-28 11:33:42berker.peksagsetstage: patch review -> resolved
2015-07-28 10:34:03vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg247514
2015-07-28 10:32:08skrahsetmessages: + msg247513
2015-07-28 09:31:49vstinnersetstatus: closed -> open

nosy: + vstinner
messages: + msg247512

resolution: fixed -> (no value)
2015-07-28 09:10:11rhettingersetstatus: open -> closed
resolution: fixed
2015-07-28 09:08:31python-devsetnosy: + python-dev
messages: + msg247509
2015-07-28 08:29:04rhettingersetmessages: - msg247505
2015-07-28 08:04:23rhettingersetmessages: + msg247505
2015-07-28 07:57:52rhettingersetassignee: rhettinger
2015-07-27 12:06:44serhiy.storchakasetnosy: + serhiy.storchaka

stage: patch review
2015-07-27 11:19:58skrahcreate