PyGILState_Release + Python2.3 = Segmentation Fault
cadavis2k2 at yahoo.com
cadavis2k2 at yahoo.com
Wed Feb 1 19:39:19 EST 2006
Kirill Simonov wrote:
> Hi,
>
> Could someone tell me why my extension module works under Python 2.4, but
> fails with Segmentation Fault under Python 2.3? Here is the stripped version:
Maybe Python threads aren't initialized? Adding a call to
PyEval_InitThreads() stops the seg fault for me in Python 2.3 on
Debian:
#include <Python.h>
static PyObject *
test_gil(PyObject *self)
{
PyGILState_STATE gs;
Py_BEGIN_ALLOW_THREADS
gs = PyGILState_Ensure();
PyGILState_Release(gs);
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef test_gil_methods[] = {
{"test_gil", (PyCFunction)test_gil, METH_NOARGS},
{NULL}
};
PyMODINIT_FUNC
init_test_gil(void) {
/* This added */
PyEval_InitThreads();
(void)Py_InitModule("_test_gil", test_gil_methods);
}
More information about the Python-list
mailing list