[issue3338] cPickle segfault with deep recursion

Facundo Batista report at bugs.python.org
Wed Jul 16 19:01:09 CEST 2008


Facundo Batista <facundo at taniquetil.com.ar> added the comment:

Confirmed in... 

Python 2.6b1+ (trunk:65017M, Jul 16 2008, 13:37:00) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2

...with a more simple case:

"""
import sys, cPickle
sys.setrecursionlimit(10405) 

class rec(object):
    child = None
    def __init__(self, counter):
      if counter > 0:
        self.child = rec(counter-1)

mychain = rec(2600)
cPickle.dumps(mychain)
"""

Note that if we put the recursion limit in 10405 we get a segfault, but
if we put it 10404, we get a "RuntimeError: maximum recursion depth
exceeded". 

Considering that 10400 is exactly 2600 * 4, maybe this is a useful hint.

Another behaviour I got: With a recursion limit big big enough, doing
rec(1670) works ok, and rec(1671) segfaults.

And a very nasty one:

I put rec(1671) to see in which recursion limit we have the conversion
of RecursionLimit to SegFault. Testing, I tried with recursion limit in
6700, and sometimes it worked ok, and sometimes it segfaulted. Yes,
*sometimes*, :(

----------
nosy: +facundobatista

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


More information about the Python-bugs-list mailing list