[mod_python] psp.PSP(req, string='hello world') causes segfault

Graham Dumpleton grahamd at dscpl.com.au
Tue Apr 26 18:12:48 EDT 2005


The segmentation fault problems are generally caused by a mismatch in 
versions
of shared libraries that various packages have been compiled against. 
The main
culprits are libexpat, MySQL client libraries and sometimes Sleepycat 
DBM. The
clash is between the version expected by PHP or Apache, and that which 
may be
expected by a Python module being used. Because it is an environment 
issue, it
may well only affect you.

Confirm that the problem only arises when psp module is imported. Ie., 
comment
out the psp import and use of psp module in handler. Ie., handler just 
returns
apache.OK.

If it no longer fails, then add in the following imports to your 
handler, leaving
psp module commented out:

import sys
import os
import marshal
import new
from cgi import escape
import anydbm, whichdb
import tempfile

These are the imports in psp module. If it crashes, start commenting 
out the
imports bit by bit to see if one in particular is causing a problem. 
The anydbm
and whichdb modules could be a problem as far as shared libraries go, 
but the
remainder should be okay.

This sort of debugging process is all I can suggest at the moment.  
I'll try
your actual code later when I get a chance.

Graham

On 27/04/2005, at 7:51 AM, dharana wrote:

>
>
> Graham Dumpleton wrote:
>> On 27/04/2005, at 7:20 AM, dharana wrote:
>>> I'm using a custom handler which has just this:
>>>
>>> -- (webapps/admin/)controller.py ----------
>>> from mod_python import *
>>>
>>> def handler(req):
>>>     content_file = psp.PSP(req, string='hello world')
>>>     return
>> Unlikely to be the cause of your problem, but you could clean this up 
>> a bit.
>> First don't use "from mod_python import *". Safer to use:
>>   from mod_python import apache
>>   from mod_python import psp
>>   def handler(req):
>>     content_file = psp.PSP(req, string='hello world')
>>     return apache.OK
>> Import everything from mod_python will really pollute your module.  
>> The
>> second thing was that you should return apache.OK and not None as 
>> later
>> can result in 500 HTTP error occurring.
>> I know you are probably trying to debug the problem and have cut 
>> things
>> down, but I think you are also missing:
>>   content_file.run()
>> Without that, nothing of the template will get displayed anyway.
>
>
> I had it setup like this as you know, I just tried to skip any module 
> loading problem and to simplify it as much as I could.
>
> I've a tail -f to the apache log file in a secondary console anyways.
>
> --- newversion.py -----------
> from mod_python import apache
> from mod_python import psp
>
> def handler(req):
>     content_file = psp.PSP(req, string='hello world')
>     content_file.run()
>     return apache.OK
> -----------------------------
>
>
> It still segfaults. I'm running it on a debian box, but I remember 
> experiencing this same problem months ago in another different server 
> (both hardware and distro, it was gentoo 2004). Please, can anyone 
> check if this happens to you too? I find it hard to believe it's 
> dharana-specific if it happens in two completely different servers.
>
> -
> dharana



More information about the Mod_python mailing list