[mod_python] deadlock when using mod_python + simplified GIL - e.g. swig wrapper of xapian (MODPYTHON-217)

Herbert Poul herbert.poul at gmail.com
Sun Apr 27 16:18:56 EDT 2008


hi,

i stumbled across a problem which has been reported a year ago called
"Python 2.3 and simplified GIL state API still causes problems.":
http://issues.apache.org/jira/browse/MODPYTHON-217
and wondered if there are any plans to fix it or any known workarounds.

in short: i am trying to get the python wrapper of xapian (based on
swig, which in turn uses simplified GIL api) working in mod_python -
but every call to this C extension ends in a deadlock.

it seems this problem arises because of the combination of mod_python
using PyEval_AcquireLock and the SWIG wrapper using simplified GIL
(PyGILState_Ensure)

is this actually anything that needs fixing in mod_python, or in the
python wrapper/SWIG ?
i would appreciate any pointers. (i have already tried using
'PythonInterpreter main_interpreter' but it doesn't help)

thanks & cu,
  herbert

P.S.: i am using apache 2.2.4 / mod_python 3.3.1 / python 2.5.1 - see
attachment for the backtrace of the deadlock.
P.P.S.: there is also a bug report for xapian because of this:
http://trac.xapian.org/ticket/185
-------------- next part --------------
(gdb) bt
#0  0xb7d2d279 in sem_wait at GLIBC_2.0 () from /lib/libpthread.so.0
#1  0xb759c06e in PyThread_acquire_lock () from /usr/lib/libpython2.5.so.1.0
#2  0xb756ab87 in PyEval_RestoreThread () from /usr/lib/libpython2.5.so.1.0
#3  0xb7591886 in PyGILState_Ensure () from /usr/lib/libpython2.5.so.1.0
#4  0xb63b99c6 in _wrap_new_Database (self=0x0, args=0x91415cc) at modern/xapian_wrap.cc:909
#5  0xb752341d in PyCFunction_Call () from /usr/lib/libpython2.5.so.1.0
#6  0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#7  0xb756ed1b in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#8  0xb7571fc4 in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0
#9  0xb750f65a in PyClassMethod_New () from /usr/lib/libpython2.5.so.1.0
#10 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#11 0xb74f4fb5 in PyClass_IsSubclass () from /usr/lib/libpython2.5.so.1.0
#12 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#13 0xb7538bfe in _PyType_Lookup () from /usr/lib/libpython2.5.so.1.0
#14 0xb7537f85 in PyType_IsSubtype () from /usr/lib/libpython2.5.so.1.0
#15 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#16 0xb756c15c in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#17 0xb7571fc4 in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0
#18 0xb7570433 in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#19 0xb7571fc4 in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0
#20 0xb7570433 in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#21 0xb7571fc4 in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0
#22 0xb750f730 in PyClassMethod_New () from /usr/lib/libpython2.5.so.1.0
#23 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#24 0xb756ed1b in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#25 0xb7570b00 in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#26 0xb7571fc4 in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0
#27 0xb750f65a in PyClassMethod_New () from /usr/lib/libpython2.5.so.1.0
#28 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#29 0xb74f4fb5 in PyClass_IsSubclass () from /usr/lib/libpython2.5.so.1.0
#30 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#31 0xb7538fb9 in _PyType_Lookup () from /usr/lib/libpython2.5.so.1.0
#32 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#33 0xb756c15c in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
---Type <return> to continue, or q <return> to quit---
#34 0xb7570b00 in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#35 0xb7570b00 in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#36 0xb7571fc4 in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0
#37 0xb7570433 in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0
#38 0xb7571fc4 in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0
#39 0xb750f65a in PyClassMethod_New () from /usr/lib/libpython2.5.so.1.0
#40 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#41 0xb74f4fb5 in PyClass_IsSubclass () from /usr/lib/libpython2.5.so.1.0
#42 0xb74ed7b7 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#43 0xb74eda33 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0
#44 0xb74efde2 in PyObject_CallMethod () from /usr/lib/libpython2.5.so.1.0
#45 0xb761b7e9 in python_handler () from /usr/lib/apache2/modules/mod_python.so
#46 0xb761dcb4 in PythonHandler () from /usr/lib/apache2/modules/mod_python.so
#47 0x08078ec9 in ap_run_handler ()
#48 0x0807c0d7 in ap_invoke_handler ()
#49 0x080891c8 in ap_process_request ()
#50 0x080864cb in ap_register_input_filter ()
#51 0x0807fe79 in ap_run_process_connection ()
#52 0x0808d0d0 in ap_graceful_stop_signalled ()
#53 0x0808d3c7 in ap_graceful_stop_signalled ()
#54 0x0808d484 in ap_graceful_stop_signalled ()
#55 0x0808df09 in ap_mpm_run ()
#56 0x08066c85 in main ()


More information about the Mod_python mailing list