[mod_python] null pointer to PyObject_CallMethod

Graham Dumpleton graham.dumpleton at gmail.com
Sat Mar 24 22:21:10 EST 2007


On 25/03/07, Nicholas Milkovits <nmilkovits at gmail.com> wrote:
> Hello,
>
> I am trying to find out the cause of a segmentation fault that occurs
> when occasionally processing database requests. The environment is
> Apache 2.0.59 (it happens when run in either prefork or threaded), Mod
> Python 3.3.1, Python 2.5 and cx_Oracle 4.3. All of this software was
> compiled from source. The database is Oracle 10g (I believe). I have
> pasted a stack trace from gdb below but here is my question:
>
> It appears the seg fault is in the database code but in frames 17 - 14
> it appears as though the func argument is a NULL pointer. How is it
> possible that execution continues after the call from python_handler
> into the interpreter when the beginning of the PyObject_CallMethod is
> supposed to raise an error if the func argument is NULL. Is this a
> problem with gdb or is there something going on that I am missing?
>
> ...
> #17 0x0064f750 in PyObject_CallMethod (o=0x0, name=0xad72456c "\001",
>     format=0x72ae92 "O") at Objects/abstract.c:1891
> #18 0x00648c32 in python_handler (req=0x993a038,
>     phase=0x71ba44 "PythonHandler") at mod_python.c:1652
> #19 0x0064a9ca in PythonHandler (req=0x993a038) at mod_python.c:2878

Since the code in mod_python calling PyObject_CallMethod() is:

    resultobject = PyObject_CallMethod(idata->obcallback, "HandlerDispatch",
                                       "O", request_obj);

and gdb isn't even showing the string literal argument for name
correctly, ie., "HandlerDispatch", I would say gdb is screwing up
somehow.

What I would suggest, in case the Oracle module hasn't be written
properly to be able to work in sub interpreters, is to force
mod_python to run your application in main Python interpreter rather
than default of sub interpreter. To do this, add:

  PythonInterpreter main_interpreter

into context where you have enabled PythonHandler for your
application. See if the problem goes away when that is done. Confirm
in your application that main interpreter is being used by dumping out
'apache.interpreter' or 'req.interpreter'.

Graham


More information about the Mod_python mailing list