[issue1069092] segfault on printing nested sequences of None/Ellipsis
Terry J. Reedy
report at bugs.python.org
Mon Mar 22 17:57:25 CET 2010
Terry J. Reedy <tjreedy at udel.edu> added the comment:
General policy is that ordinary code (not using, for instance, ctypes) should not crash or segfault the interpreter. I believe there is a 'crashers' subdirectory somewhere in the tree for examples that do so that people so inclined can work on them.
The OP reported a crash on 2.3/2.4a on Linux, but not 1.5. I could not reproduce it on 2.2 on Windows. Instead, I (properly) got an exception. Trying again with 3.1, I get a similar exception: RuntimeError: maximum recursion depth exceeded while getting the repr of a tuple. List instead of tuple does similar.
If
>>> t=None,
>>> for i in range(50000): t = t,None
>>> print(t)
still crashes on 2.6/2.7, at least with Linux, then there is still a bug to be fixed and the issue should be left open. If it now raises an exception as above, then this should be closed as fixed.
I am pretty sure this issue has nothing to do with None and Ellipsis but only with the structure (not necessarily a sequence) being deeply, deeply nested. So I think the title should be: "Segfault on printing deeply nested structures."
I think the deeper issue is the use of recursion on the C stack to print. If the print routine instead usee iteration with an auxiliary Python stack (list), then there should be no stack overflow to worry about. [When in increase the recursion limit to 100000 and try to print the 50000 nested tuples, I get "MemoryError: stack overflow" instead of the RuntimeError above. So there might be more than one fix needed.]
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1069092>
_______________________________________
More information about the Python-bugs-list
mailing list