[New-bugs-announce] [issue9670] Exceed Recursion Limit in Thread

Jared Lang report at bugs.python.org
Tue Aug 24 15:23:21 CEST 2010


New submission from Jared Lang <jslang at mail.ucf.edu>:

Recursion within a thread on OSX can result in a crash by exceeding the systems recursion limit.  Recursion behaves as expected if not in thread, meaning it throws a RunTimeError with the message "maximum recursion depth exceeded."

The crash is able to be avoided if the recursion limit is set to a lower number, ie. 800, via sys.setrecursionlimit.

Example program which crashes on OSX:


>>> def f():
...     return f()
... 
>>> import threading
>>> thread = threading.Thread(target=f)
>>> thread.start()
Bus error


Alternatively, the following works as expected:


>>> import sys
>>> def f():
...     return f()
... 
>>> import threading
>>> thread = threading.Thread(target=f)
>>> sys.setrecursionlimit(800)
>>> thread.start()

>>> Exception in thread Thread-1:
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 484, in run
    self.__target(*self.__args, **self.__kwargs)
  File "<stdin>", line 2, in f
  File "<stdin>", line 2, in f
  File "<stdin>", line 2, in f
  File "<stdin>", line 2, in f
  File "<stdin>", line 2, in f
  File "<stdin>", line 2, in f
...

RuntimeError: maximum recursion depth exceeded

----------
assignee: ronaldoussoren
components: Macintosh
messages: 114787
nosy: jaredlang, ronaldoussoren
priority: normal
severity: normal
status: open
title: Exceed Recursion Limit in Thread
type: crash
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9670>
_______________________________________


More information about the New-bugs-announce mailing list