classification
Title: deeply nested filter segfaults
Type: crash Stage: needs patch
Components: Interpreter Core Versions: Python 3.4, Python 3.3, Python 3.2, Python 3.1, Python 2.7, Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alex, arigo, benjamin.peterson, ezio.melotti
Priority: normal Keywords:

Created on 2012-02-14 15:58 by alex, last changed 2012-02-14 17:11 by arigo.

Messages (2)
msg153344 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2012-02-14 15:58
http://paste.pocoo.org/show/550884/ will reliably segfault Python3 on all platforms (similar versions for Python2 using itertools work)
msg153353 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2012-02-14 17:11
The issue is a stack exhaustion.  Examples can be trivially made for any iterator that takes another iterator as argument: itertools.takewhile(), zip() in Python3, etc. etc.

It's just one of many places where CPython does a recursion without checking the recursion depth.  CPython still works, based on the resonable assumption that doing such a recursion here is obscure.

Someone seriously bored could start with some C-based callgraph builder; or alternatively use PyPy, which finds such recursions automatically in its own source, and compare all places where a recursion check is inserted with the corresponding place in CPython.  There are a large number of them (761, not counting the JIT), so be patient :-(
History
Date User Action Args
2012-02-14 17:11:20arigosetnosy: + arigo
messages: + msg153353
2012-02-14 16:20:23ezio.melottisetnosy: + ezio.melotti

type: crash
stage: needs patch
2012-02-14 15:58:25alexcreate