[ZODB-Dev] ZEO pack
Toby Dickenson
tdickenson@geminidataloggers.com
Thu, 27 Sep 2001 15:14:17 +0100
> Did this sub-thread start by worrying about pickles of recursive
> objects? Pickle handles cycles in object references just fine.
Pickle usually handles cycles well, but it does have a switch to turn this
cycle-protection off as an optimisation.
ZEO's zrpc.py uses this switch, which means a ZEO client will dump core if a
cyclic object is used as a parameter to a method which is marshalled to the
ZEO server. Note that this doesnt affect objects stored in ZEO, just objects
passed as parameters to ZEO methods.
This is a bad idea IMO, even though I dont believe it is possible to exploit
this in the current Zope and ZEO source.
Here is a python session mixing the relevant code from zrpc.py and some code
posted earlier in this thread:
Python 2.1.1 (#3, Sep 10 2001, 15:09:44)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import cPickle
>>> # We create a special fast pickler! This allows us
... # to create slightly more efficient pickles and
... # to create them a tad faster.
... pickler=cPickle.Pickler()
>>> pickler.fast=1 # Don't use the memo
>>> dump=pickler.dump
>>> a=[]
>>> a.append(a)
>>> a
[[...]]
>>> dump(a)
Segmentation fault (core dumped)