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.
Created on 2012年03月20日 04:37 by aaron315, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg156379 - (view) | Author: aaron315 (aaron315) | Date: 2012年03月20日 04:37 | |
alist=list(range(5)) alist.extend(enumerate(alist)) the computer will down !!! |
|||
| msg156380 - (view) | Author: Brian Curtin (brian.curtin) * (Python committer) | Date: 2012年03月20日 05:13 | |
I just get a MemoryError. Do you actually receive a crash? |
|||
| msg156382 - (view) | Author: aaron315 (aaron315) | Date: 2012年03月20日 06:32 | |
Have not been able to respond in a lower performance on the computer running, I restart the computer; On another computer, indeed MemoryError。 |
|||
| msg156383 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2012年03月20日 08:09 | |
I can reproduce this with Python 3.2 on Linux-2.4.32/i686 with 512M of RAM. The machine does not crash, it freezes completely in the same manner as with a fork bomb. A hard reboot is required. |
|||
| msg156384 - (view) | Author: Petri Lehtinen (petri.lehtinen) * (Python committer) | Date: 2012年03月20日 08:32 | |
This has the same effect: a = list(range(5)) a.extend(iter(a)) So the problem is not in enumerate but in list.extend() |
|||
| msg156385 - (view) | Author: Charles-François Natali (neologix) * (Python committer) | Date: 2012年03月20日 08:43 | |
I think you're simply running OOM, and Linux is thrashing to death.
If you wait long enough, the process should get nuked by the OOM killer (well, in theory).
What happens if you disable swap altogether ('swapoff -a')?
You can also change to strict overcommitting ('echo 2 > /proc/sys/vm/overcommit_memory').
Anyway, I guess you would get the same effect by simply running
list(range(<huge number>))...
|
|||
| msg156448 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2012年03月20日 19:12 | |
This a feature, not a bug. Lists are allowed to mutate during iteration and there are valid use cases for doing so (adding pending tasks, etc.) # Demonstrate list mutation during iteration # Infinite loop that overflows memory s = [None] for x in s: s.append(x) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:28 | admin | set | github: 58578 |
| 2012年03月20日 19:12:50 | rhettinger | set | status: open -> closed nosy: + rhettinger messages: + msg156448 resolution: not a bug |
| 2012年03月20日 11:38:02 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola |
| 2012年03月20日 08:43:54 | neologix | set | nosy:
+ neologix messages: + msg156385 |
| 2012年03月20日 08:32:32 | petri.lehtinen | set | nosy:
+ petri.lehtinen messages: + msg156384 title: enumerate() lead to system crashes -> list.extend() called on an iterator of the list itself leads to an infinite loop |
| 2012年03月20日 08:09:32 | skrah | set | type: performance -> resource usage messages: + msg156383 nosy: + skrah |
| 2012年03月20日 06:32:42 | aaron315 | set | messages: + msg156382 |
| 2012年03月20日 05:13:05 | brian.curtin | set | nosy:
+ brian.curtin messages: + msg156380 |
| 2012年03月20日 04:37:12 | aaron315 | create | |