Segmentation fault when loading object with slots

Bug #262158 reported by Richard Collins
2
Affects Status Importance Assigned to Milestone
ZODB
Fix Released
Undecided
Unassigned

Bug Description

I am getting a segmentation fault on line 472 of src/persistent/cPersistence.c of version 3.8.1b4 of ZODB. I'm using version 2.5 of Python.

This happened when I added a __slots__ declaration to a class. The segmentation fault occurs when an instance of this class is loaded from the object database. The problem goes away when i remove the slots declaration.

Inspection of cPersistence.c suggest the if statement on line 464 needs an else for when dict is null.

    450 static PyObject *
    451 pickle___setstate__(PyObject *self, PyObject *state)
    452 {
    453 PyObject *slots=NULL;
    454
    455 if (PyTuple_Check(state)) {
    456 if (!PyArg_ParseTuple(state, "OO:__setstate__", &state, &slots))
    457 return NULL;
    458 }
    459
    460 if (state != Py_None) {
    461 PyObject **dict;
    462
    463 dict = _PyObject_GetDictPtr(self);
    464 if (dict) {
    465 if (!*dict) {
    466 *dict = PyDict_New();
    467 if (!*dict)
    468 return NULL;
    469 }
    470 }
    471
    472 if (*dict) {
    473 PyDict_Clear(*dict);
    474 if (PyDict_Update(*dict, state) < 0)
    475 return NULL;
    476 }

Revision history for this message
Jim Fulton (jim-zope) wrote :

The fix for this is comitted. Now, you'll get a type error in a situation like this.

The slot support in persistent is a bit brittle. If we're going to support slots, we need to do a lot more work.

Changed in zodb:
status: New → Fix Committed
Revision history for this message
Tres Seaver (tseaver) wrote :

Fix released with ZODB 3.9.0:

 http://pypi.python.org/pypi/ZODB3/3.9.0#id14

Changed in zodb:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.