[Zope-dev] Crashing problem? Python workaround?!

Matthew T. Kromer matt@zope.com
Wed, 27 Mar 2002 16:37:49 -0500


Hey fellow Zopistas:

If you're still experiencing crashing problems with Python 2.1.2, and 
Zope, please consider trying the following test:

 From a clean Python build tree, modify Include/object.h line 587.

#define PyTrash_UNWIND_LEVEL 50

make this read

#define PyTrash_UNWIND_LEVEL 5000000

Rebuild Python, and Zope, with the new patched Python.  Test it.

If this makes your problem go away, please post here to the list.

Technical details:  this patch prevents Python from storing objects in 
an internal "trashcan" of objects which need to be deleted, but aren't 
-- a way to avoid C stack recursion.  The trashcan code is not safe from 
the normal garbage collector; it steals a few fields in the object that 
the GC depends on (the reference count and the object type field, in 
fact) and so items in the trashcan will cause the garbage collector to 
crash with a segmentation fault.

Objects only go into the trashcan when a recursive delete is detected, 
with a depth defined by PyTrash_UNWIND_LEVEL.  Bumping this number up to 
a large number has the effect of disabling the trashcan module, at the 
expense of the C stack (because all of those recursive deletes CAN 
happen then.)

Pythonlabs found this today after much assistance from the folks on 
#zope on the irc.openprojects.net system; particularly, Leonardo Rochael 
Almeida's assistance has been extremely valuable in isolating this problem.

This is an intermediate workaround until Pythonlabs develops an official 
fix.  However, by using this workaround, you do not need the specially 
modified ZServerPublisher module I coded.

-- 
Matt Kromer
Zope Corporation  http://www.zope.com/