Author esrever_otua
Recipients esrever_otua
Date 2008-07-11.04:54:17
SpamBayes Score 0.00112918
Marked as misclassified No
Message-id <1215752062.17.0.76482457949.issue3338@psf.upfronthosting.co.za>
In-reply-to
Content
In at least Python 2.4, using cPickle.Pickler to try and pickle a nested
chain of objects more than about 2590 objects deep causes the Python
interpreter to segfault. This doesn't seem to happen when using the pure
Python pickle module.

It is not memory related (witness that the pure Python module can
achieve depths much greater than this just fine), and does not seem to
be directly related to system architecture (happens on both i386 and on
x86_64 (32bit and 64bit)).

Sample interpreter session to replicate:
>>> # Let's cause cPickle to segfault:
>>> from cPickle import Pickler as cPickler
>>> class rec:
...   child = None
...   def __init__(self, counter):
...     if counter > 0:
...       self.child = rec(counter-1)
...
>>> import sys
>>> sys.setrecursionlimit(10000)
>>> mychain = rec(2600)
>>> from cStringIO import StringIO
>>> stream = StringIO()
>>> p = cPickler(stream, 1)
>>> res = p.dump(mychain)
Segmentation fault

And now the same steps again using the pure Python Pickler:
>>> import sys
>>> from pickle import Pickler as pPickler
>>> from cStringIO import StringIO
>>> class rec:
...   child = None
...   def __init__(self, counter):
...     if counter > 0:
...       self.child = rec(counter-1)
... 
>>> sys.setrecursionlimit(20000)
>>> mychain = rec(2600)
>>> stream = StringIO()
>>> p = pPickler(stream, 1)
>>> p.dump(mychain)
>>> len(stream.getvalue())
48676
>>>
History
Date User Action Args
2008-07-11 04:54:23esrever_otuasetspambayes_score: 0.00112918 -> 0.00112918
recipients: + esrever_otua
2008-07-11 04:54:22esrever_otuasetspambayes_score: 0.00112918 -> 0.00112918
messageid: <1215752062.17.0.76482457949.issue3338@psf.upfronthosting.co.za>
2008-07-11 04:54:21esrever_otualinkissue3338 messages
2008-07-11 04:54:19esrever_otuacreate