[Zope-dev] Re: more on the segfault saga
Leonardo Rochael Almeida
leo@hiper.com.br
25 Mar 2002 22:51:41 -0300
This is a MIME-formatted message. If you see this text it means that your
E-mail software does not support MIME-formatted messages.
--=_spitfire-25133-1017107502-0001-2
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Hello segfaulters and others interested in Zope instability issues!
Our demi-god Matt Kromer from ZopeCorp has come up with a possible way
to corner the instability issue AND give you a stable, cycle-garbage
collecting Zope.
Since the problem seems, so far, to be caused by the Python Restricted
Compiler (which is used in everything from dtml expressions to python
scripts to other stuff) not completing fully collectable objects before
the Python cycle garbage collector finds them, the solution is to lock
out the gc while creating these objects. The only easy way to do this
currently is to disable the automatic gc and run manual garbage
collections only when we're pretty sure no one else is running, and at
the same time not letting anyone else run when we're running the gc.
While I can't speak for Matt but since this is a fairly urgent matter, I
believe he agrees that those experiencing segfaults are encouraged to
replace <Zope>/ZServer/PubCore/ZServerPublisher.py with the attached
file, which should work on 2.4.x and 2.5.x series Zopes, and report your
instability results.
This is the same file that can be found at:
http://zope.org/Members/matt/ZServerPublisher.py
with the difference that my version has some lines removed that are only
interesting for those that applied Matt's cprof patches mentioned
earlier on this list (which, I bet, means only me :-).
The file is small enough so that you can manually look and see that I've
installed no trojans in it :-) but those of a paranoid nature are
encouraged to download Matt's version and remove the two lines that
mention 'cprof'.
We're close guys, very close.
Cheers, Leo
PS: standard disclaimers: I don't speak for anyone else but me and I
won't be held responsible for anything you do to your site based on the
aforementioned intructions. If you break your site with them, you get to
keep both pieces :-)
--
Ideas don't stay in some minds very long because they don't like
solitary confinement.
--=_spitfire-25133-1017107502-0001-2
Content-Type: text/x-python; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=ZServerPublisher.py
###########################################################################=
###
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved=
.
#=20
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#=20
###########################################################################=
###
from ZPublisher import publish_module
import ThreadLock
gc_lock =3D ThreadLock.allocate_lock()
active_threads =3D [0,]
class ZServerPublisher:
def __init__(self, accept):
import os
import sys
import gc
gc.disable()
while 1:
try:
name, request, response=3Daccept()
gc_lock.acquire()
active_threads[0] =3D active_threads[0] + 1
gc_lock.release()
publish_module(
name,
request=3Drequest,
response=3Dresponse)
finally:
response._finish()
request=3Dresponse=3DNone
gc_lock.acquire()
a =3D active_threads[0] - 1
if a =3D=3D 0:
#sys.stderr.write("Invoking gc.collect()\n")
gc.collect()
else:
#sys.stderr.write("Skipping gc.collect(), %d threads act=
ive\n"% a)
pass
active_threads[0] =3D a
gc_lock.release()
--=_spitfire-25133-1017107502-0001-2--