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: AssertionError on collections.deque().count(1)
Type: crash Stage:
Components: Extension Modules Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Andrew.Brown, benjamin.peterson, georg.brandl, rhettinger, vstinner
Priority: release blocker Keywords: needs review, patch

Created on 2011-01-25 12:36 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug.py vstinner, 2011-01-25 12:36
bug_simplified.py Andrew.Brown, 2011-01-25 15:58
deque.patch rhettinger, 2011-01-25 20:10 Deque patch
Messages (5)
msg127001 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-01-25 12:36
Attached script, bug.py, ends with:

$ python3.2 source2.py 
deque.remove(x): x not in deque
python: ./Modules/_collectionsmodule.c:536: deque_count: Assertion `leftblock->rightlink != ((void *)0)' failed.
Abandon (core dumped)
msg127017 - (view) Author: Andrew Brown (Andrew.Brown) Date: 2011-01-25 15:58
This bug trigger can be simplified down, see my attached bug_simplified.py

The problem seems to be in deque_count(). What's happening is that after the rotations, the 16 items reside in the last 16 slots of one block.

In deque_count()'s for loop, the block pointer is incremented regardless of whether the loop has another iteration to go or not. Thus, it's trying to grab the (nonexistant) next block, even though the for loop would have exited anyways.
msg127046 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-01-25 20:10
Victor, thanks for the bug report.  Score one for fuzzing.
Andrew, thanks for the analysis and simplified crasher.
See attached patch.
msg127056 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-01-25 21:31
deque.patch: I'm unable to say if the patch is correct or not, but it is always a good thing to remove asser(...) :-)
msg127059 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-01-25 21:45
Fixed in r88191 and r88192.
History
Date User Action Args
2022-04-11 14:57:11adminsetgithub: 55213
2011-01-25 21:45:59rhettingersetnosy: georg.brandl, rhettinger, vstinner, benjamin.peterson, Andrew.Brown
components: + Extension Modules, - Library (Lib)
2011-01-25 21:45:44rhettingersetstatus: open -> closed

messages: + msg127059
resolution: fixed
nosy: georg.brandl, rhettinger, vstinner, benjamin.peterson, Andrew.Brown
2011-01-25 21:31:40vstinnersetnosy: georg.brandl, rhettinger, vstinner, benjamin.peterson, Andrew.Brown
messages: + msg127056
2011-01-25 20:10:48rhettingersetfiles: + deque.patch
priority: normal -> release blocker

nosy: + georg.brandl, benjamin.peterson
messages: + msg127046

keywords: + needs review, patch
2011-01-25 18:26:39rhettingersetassignee: rhettinger

nosy: + rhettinger
2011-01-25 15:58:43Andrew.Brownsetfiles: + bug_simplified.py
nosy: + Andrew.Brown
messages: + msg127017

2011-01-25 12:44:40vstinnersetversions: + Python 2.7
2011-01-25 12:36:08vstinnercreate