[Zope3-dev] --without-cycle-gc needed?

Matt Behrens matt@zigg.com
Sat, 2 Mar 2002 16:57:48 -0500


--5mCyUwZo2JvN/JJP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Feb 26, 2002 at 11:46:54AM -0500, Jeremy Hylton wrote:

> > Program received signal SIGSEGV, Segmentation fault.
> > 0x22e0a in visit_move (op=0x40294310, tolist=0xdfbf8c6c)
> >     at Modules/gcmodule.c:96
> > 96              node->gc.gc_prev->gc.gc_next = node->gc.gc_next;
> >
> > If I compile up python 2.2 with --without-cycle-gc, no trouble (so
> > far).  I was advised to bring this to everyone's attention...
> 
> Oh, you've got trouble alright.  You just don't have the garbage collector
> to catch it for you.

You're right, but it wasn't OOBTree's fault.  I relearned gdb today,
and examining 0x40294310 revealed PyPersist_Type, which can't be
garbage collected because it has no GC head structure.  I looked
where it was trying to find a GC head structure, and found it was
looking in the last several bytes of persist_mapping.  It should
have never gone to the GC.

My theory as to why this wasn't an issue on other platforms is that
OpenBSD has rather crufty a.out tools rather than the latest shiny
GNU stuff, and we were filling the rest of persist_mapping with
0x90909090 (i386 no-ops) rather than 0x00000000, which would
(erroneously) cause the check in visit_move (gc->gc.gc_next != NULL)
to determine that it didn't have to call gc_list_remove.

I fixed it by removing Py_TPFLAGS_HEAPTYPE from tp_flags, so that
type_is_gc would properly stop the GC from trying to collect it --
after all, you can't collect garbage from the middle of code...
Patch attached.


--5mCyUwZo2JvN/JJP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="lib-python-Persistence-cPersistence_c.patch"

Index: cPersistence.c
===================================================================
RCS file: /cvs-repository/Zope3/lib/python/Persistence/Attic/cPersistence.c,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 cPersistence.c
--- cPersistence.c	21 Feb 2002 21:33:31 -0000	1.1.2.9
+++ cPersistence.c	2 Mar 2002 21:47:04 -0000
@@ -650,7 +650,7 @@
     (getattrofunc)persist_getattro,	/* tp_getattro */
     (setattrofunc)persist_setattro,	/* tp_setattro */
     0,					/* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HEAPTYPE |
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | 
     Py_TPFLAGS_BASETYPE, 		/* tp_flags */
     0,					/* tp_doc */
     (traverseproc)persist_traverse,	/* tp_traverse */

--5mCyUwZo2JvN/JJP--