[Python-bugs-list] [ python-Bugs-576419 ] Infinite recursion in Pickle

noreply@sourceforge.net noreply@sourceforge.net
Fri, 02 Aug 2002 13:42:39 -0700


Bugs item #576419, was opened at 2002-07-02 11:02
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=576419&group_id=5470

Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
>Priority: 3
Submitted By: Oleg Broytmann (phd)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Infinite recursion in Pickle

Initial Comment:
Pickle falls into infininite recursion, cPickle crashed
(segfault on Linux, bus error on FreeBSD). See the
attached file. There is initial pickle (just a very
simple though somewhat large tree of bookmarks;
unfortunately lesser tree does not trigger the bug);
bkmk_objects.py module that includes class definitions
for the pickled object, and simple test program that
demonstrates the bug.

The program loads initial pickle, runs a function upon
it and saves the pickle back. The function runs through
the entire tree and creates backlinks - every object
got a link to its parent folder.

So it seems the bug is related to pickling objects with
loops.

When I changed builtin list as a parent class of Folder
to UserList (and recreated initial pickle) the bug
disappeared, so I think the bug is related to pickling
new classes.

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-02 16:42

Message:
Logged In: YES 
user_id=6380

Oleg, could it be that your data structure is just very
deeply nested? On my machine (RedHat Linux 7.2), your test
program completes without problem, so there doesn't seem to
be something in the data that inherently triggers a bug.
However, when I apply Martin von Loewis's patch from SF bug
576084, cPickle raises RuntimeError: maximum recursion depth
exceeded. I'm guessing that you are building what is in
essence a very long doubly-linked list; the pickle algorithm
necessarily has to enter a recursion level for each list
node in this case.

Switching to UserList probably reduces the number of stack
frames per recursion level and that would explain that it
doesn't fail.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-02 16:26

Message:
Logged In: YES 
user_id=6380

Mmm, interesting.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=576419&group_id=5470