On 25-sep-04, at 6:41, Tim Peters wrote: > [George Yoshida] >>> It does not always go into an infinite loop. I was bitten by this: >>> >>>>>> x = [] >>>>>> x.extend(-y for y in x) >>> Segmentation fault > > [Bob Ippolito] >> No algorithm that requires infinite memory will run for an infinite >> amount of time on a finite computer. Of course it should raise an >> exception instead of segfaulting though.. could it be blowing the >> stack? > > No, its stack use is bounded (and small) no matter how long it runs. I get a bus error on OSX (although with a slightly out of date python2.4 from CVS). Why should this loop at all? x is the empty list, and the generator comprehension should therefore end up with an empty sequence. It's not like your initial example where the list was non-empty to at the start. It crashes because of an Py_INCREF(item) at line 2727 in listobject.c where item is NULL: 2722 assert(PyList_Check(seq)); 2723 2724 if (it->it_index < PyList_GET_SIZE(seq)) { 2725 item = PyList_GET_ITEM(seq, it->it_index); 2726 ++it->it_index; 2727 Py_INCREF(item); 2728 return item; 2729 } 2730 2731 Py_DECREF(seq); BWT. seq is null as well.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4