classification
Title: stack overflow evaluating eval("()" * 30000)
Type: crash Stage:
Components: Interpreter Core Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, benjamin.peterson, gagenellina, terry.reedy
Priority: low Keywords:

Created on 2009-04-15 23:37 by gagenellina, last changed 2010-08-04 23:43 by terry.reedy.

Messages (4)
msg86006 - (view) Author: Gabriel Genellina (gagenellina) Date: 2009-04-15 23:37
Originally reported by Juanjo Conti at PyAr: 
http://blog.gmane.org/gmane.org.user-groups.python.argentina/
day=20090415

Evaluating this expression causes a stack overflow, and the Python 
interpreter exits abnormally:

eval("()" * 30000)

3.0.1, 2.6, 2.5 and current 2.x trunk all fail on Windows; the original 
reporter was likely using Linux. Some versions may require a larger 
constant instead of 30000.

2.4 isn't affected; it raises a "TypeError: 'tuple' object is not 
callable" as expected, even for extremely long sequences.

Alberto Bertogli said: inside eval, symtable_visit_expr() (Python/
symtable.c) is called recursively (thru the VISIT/VISIT_SEQ macros), 
eventually taking all stack space.
msg86008 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-04-15 23:51
This is a pathological case. I suppose we have to add a recursion
counter to the compiler struct.
msg99785 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-02-22 16:56
Another case from issue7985:
eval('l'+'[0]'*999999)
msg112925 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-04 23:43
On 3.1.2, WinXP, I immediately get
TypeError: 'tuple' object is not callable
so this seems to have been fixed for 3.x.
If released 2.7 is ok, we can close this.
History
Date User Action Args
2010-08-04 23:43:16terry.reedysetnosy: + terry.reedy

messages: + msg112925
versions: - Python 2.6, Python 2.5, Python 3.0
2010-02-22 16:56:42amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg99785
2010-02-22 16:56:38amaury.forgeotdarclinkissue7985 superseder
2009-04-15 23:51:22benjamin.petersonsetpriority: low
nosy: + benjamin.peterson
messages: + msg86008

2009-04-15 23:37:36gagenellinacreate