This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author andivajda
Recipients
Date 2004-11-30.01:54:36
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
PyLucene (http://pylucene.osafoundation.org) wraps
libgcj with python. Python objects are also wrapped by
java objects. The ref count of the python is
incremented in the wrapping java object constructor and
is decremented in the wrapping java object's finalize()
method. Yes, finalize() is not a reliable means of
cleaning memory up but, so far, I wasn't able to figure
out a better way to do this. The finalize() method runs
in its own libgcj finalizer thread.
It has to acquire the GIL before it can call
Py_DECREF() is my understanding. The java finalize()
calls this code in PyLucene:

void finalizeObject(PyObject *object)
{
#if PY_VERSION_HEX >= 0x02040000
    PyGILState_STATE state = PyGILState_Ensure();

    Py_DECREF(object);
    PyGILState_Release(state);
#endif
}

When compiled with python 2.4c1, this mostly works.
Except that it deadlocks, every now and then. If I
comment this code out, no deadlock. I also verified
that the finalizer is called at most once per such
object. I realize that reproducing this bug maybe hard,
building PyLucene is not particularly easy, unless you
have gcj ready.
If you contact me, I'm more than willing to help in
providing all that's needed to reproduce this. I've
seen the deadlock on Mac OS X 10.3.6, my main
development OS.
For what it's worth, I also tried this with python
2.3.4 (including threadmodule.c patch made in
September, related to GIL function usage).
History
Date User Action Args
2007-08-23 14:27:53adminlinkissue1075703 messages
2007-08-23 14:27:53admincreate