New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double deallocation on iterator exhausting #70681
Comments
Following example causes double deallocation of a sequence and crashing. class A(list):
def __del__(self):
next(it)
it = iter(A())
next(it) The same is for subclass of tuple, str, bytes and bytearray. Proposed patch fixes this issue. |
Updated patch fixes also set, dict and os.scandir() iterator. May be sqlite3 cursor needs a fix, but it is too complicated. |
TODO: After resolving bpo-26492 add the test for array. |
Fixed test for OrderedDict. Tests for list and tuple are moved up to seq_tests.py. |
Hi Serhiy, I tried the short example you gave, but it doesn't crash. I'm getting: Exception ignored in: <bound method A.__del__ of []>
Traceback (most recent call last):
File "./test.py", line 5, in __del__
next(it)
StopIteration
Exception ignored in: <bound method A.__del__ of []>
Traceback (most recent call last):
File "./test.py", line 5, in __del__
next(it)
StopIteration
Traceback (most recent call last):
File "./test.py", line 8, in <module>
next(it)
StopIteration Am I missing something? |
It crashes in debug build. |
Could anyone please look at the patch? I'm not sure about organizing tests. |
New changeset 905b5944119c by Serhiy Storchaka in branch '3.5': New changeset 73ce47d4a7b2 by Serhiy Storchaka in branch 'default': New changeset cff06d875678 by Serhiy Storchaka in branch '2.7': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: