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: Crash when a set is changed during iteration
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: python-dev, rhettinger, serhiy.storchaka
Priority: high Keywords:

Created on 2015-07-07 08:09 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg246394 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-07-07 08:09
Changeset c9782a9ac031 caused segmentation fault when underlying table of the set is reallocated but the number of set elements is kept the same during iteration. Crash reproducer:

s = set(range(100))
s.clear()
s.update(range(100))
si = iter(s)
s.clear()
a = list(range(100))
s.update(range(100))
list(si)
msg246430 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015-07-07 17:20
The test for the size being constant has always been weak (it was possible to produce a unstable and incorrect but non-crashing result).  I was considering checking both size and that the table itself hasn't moved.
msg246442 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-07-07 22:29
New changeset 648c9fb3bdf5 by Raymond Hettinger in branch 'default':
Issue 24581: Revert c9782a9ac031 pending a stronger test for mutation during iteration.
https://hg.python.org/cpython/rev/648c9fb3bdf5
msg246467 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-07-08 19:49
Thanks.
msg246468 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-07-08 20:03
New changeset 8644744f53ce by Serhiy Storchaka in branch '3.4':
Added regression test for issue24581.
https://hg.python.org/cpython/rev/8644744f53ce

New changeset cfb84be6c7fc by Serhiy Storchaka in branch '2.7':
Added regression test for issue24581.
https://hg.python.org/cpython/rev/cfb84be6c7fc

New changeset 844bd42326fa by Serhiy Storchaka in branch '3.5':
Added regression test for issue24581.
https://hg.python.org/cpython/rev/844bd42326fa

New changeset 9d296d5b6941 by Serhiy Storchaka in branch 'default':
Added regression test for issue24581.
https://hg.python.org/cpython/rev/9d296d5b6941
History
Date User Action Args
2022-04-11 14:58:18adminsetgithub: 68769
2015-07-08 20:03:37python-devsetmessages: + msg246468
2015-07-08 19:49:27serhiy.storchakasetmessages: + msg246467
stage: needs patch -> resolved
2015-07-07 22:32:30rhettingersetstatus: open -> closed
resolution: fixed
2015-07-07 22:29:32python-devsetnosy: + python-dev
messages: + msg246442
2015-07-07 17:20:31rhettingersetmessages: + msg246430
2015-07-07 17:16:59rhettingersetpriority: normal -> high
2015-07-07 17:16:53rhettingersetassignee: rhettinger
2015-07-07 08:09:09serhiy.storchakacreate