-
Notifications
You must be signed in to change notification settings - Fork 108
Recursion Memory errors
-
Affected Components : builtin
-
Operating System : Linux
-
Python Versions : 2.6.x, 2.7.x, 3.1.x, 3.2.x
-
Reproducible : Yes
import sys
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
1
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
sys.exit(0)
To reproduce the problem copy the source code
in a file and execute the script using the following command syntax:
$ python -OOBRtt test.py
Alternatively you can open python in interactive mode:
$ python -OOBRtt <press enter>
Then copy the lines of code into the interpreter.
Script execution generates a memory error like in the two following cases:
s_push: parser stack overflow
MemoryError
python -OOBRtt test.py
s_push: parser stack overflow MemoryError
Python has internal recursion limits but is lacking controls on code recursion and there is no logic to evaluate system parameters and capabilities to scale the limit dynamically.
As a consequence the interpreter generates a MemoryError
where in fact is a recursion error but the deep call stack of the recursion would require an instantiation of each object and this generates the memory related error.
We are not aware on any easy solution other than trying to avoid deep recursion calls like in cases as the one examined.
[Python sys module][01] [01]:https://docs.python.org/2/library/sys.html
Main site: pythonsecurity.org
OWASP Page: owasp.org/index.php/OWASP_Python_Security_Project