[mod_python] Segfault with Vampire

Graham Dumpleton grahamd at dscpl.com.au
Sat Oct 22 19:41:03 EDT 2005



On 23/10/2005, at 9:09 AM, Ian Stokes-Rees wrote:

> OK, That looks like it is probably it (changing to just mod_python  
> and then importing pyexpat does cause the seg fault).
>
> The problem is that after upgrading the installed library to expat  
> 1.95.8 (same as Python -- see below), and restarting Apache, I  
> still get seg faults.
>
> Do I need to rebuild Apache, mod_python, or vampire?  I wouldn't  
> have thought so if they are dynamically linked...

Depending on how old the OS expat was, there is a chance that Apache
may been to be rebuilt but I also wouldn't have expected that it would
be needed. I don't believe that mod_python would need to be rebuilt and
Vampire is just pure Python code so nothing to rebuild there. I am
presuming that when you say it still crashes that that is only when
pyexpat is being imported???

Did you try an actual Apache "stop" and then "start", rather than a  
"restart".
There shouldn't be a different but one never knows? If possible can you
reboot the box in case some sort of strange caching is occurring?

Did you also confirm using "ldd" that the "httpd" Apache application  
is picking
up the one in /usr/lib that you replaced. I wouldn't have expected it on
Linux where libexpat is a standard library, but I know that on other  
systems
where expat isn't available, Apache will install its own version  
elsewhere.

A few other things I can suggest to try and debug things. First is,  
after
restarting Apache but before making a request against any mod_python
code, find the process ID of one of Apache process and run:

   /usr/sbin/lsof -p 3625 | grep expat

You will probably need to run this as root or yourself if you ran Apache
manually. This should yield something like:

   httpd   3625 root  mem    REG     253,0   123552    6409040 /usr/ 
lib/libexpat.so.0.5.0

and tells you exactly which libexpat shared library is being used in  
case
ldd actually lied for some reason. Obviously you want it to be using the
new library.

Without involving Apache at all, I think you can induce the same  
conditions
by forcing Python to load libexpat.so when it is run, this is done  
using the
LD_PRELOAD environment variable. I have set it here on the command line
the same time I ran Python.

   [grahamd at dscpl grahamd]$ LD_PRELOAD=/usr/lib/libexpat.so python
   Python 2.3.3 (#1, May  7 2004, 10:31:40)
   [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
   Type "help", "copyright", "credits" or "license" for more  
information.
   >>> import pyexpat
   >>> pyexpat.version_info
   (1, 95, 8)
   >>>

If there is still a problem, I would expect that loading of pyexpat  
would possibly
cause this to crash as well, but not totally sure. You can run "lsof"  
against this
Python process to confirm it did load libexpat.so.

Anyway, a few things for you to try. Let us know how you go.

Graham

> Python 2.4.1 (#1, Aug 31 2005, 15:59:42)
> [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-42)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pyexpat
> >>> pyexpat.version_info
> (1, 95, 8)
>
> [stokes at grid stokes]$ strings /usr/lib/libexpat* | grep expat_
> expat_external.h
> expat_1.95.8
> expat_1.95.8
> expat_1.95.8
> expat_1.95.5
> expat_1.95.8
>
> Graham Dumpleton wrote:
>
>> Vampire imports xmlrpclib, so you may be affected by the expat  
>> library
>> version mismatch problem. See:
>>   http://www.modpython.org/pipermail/mod_python/2005-October/ 
>> 019348.html
>> for some details. Use the prev/next links for that mailing list  
>> thread to
>> go back through the discussion to get the context.
>> Simplest way to check is to put PythonHandler back to "boo" and in
>> "boo.py" add:
>>   import xmlrpclib
>> If it crashes when access, it is the expat problem and nothing to  
>> do with
>> Vampire itself.
>> In short, upgrade expat to a newer version, or at least the same  
>> version
>> as embedded in Python. See mailing list discussion for how to find  
>> out.
>> Graham
>> On 22/10/2005, at 5:46 AM, Ian Stokes-Rees wrote:
>>
>>> Hi,
>>>
>>> I have Apache, Python, and mod_python setup as follows:
>>>
>>>  Apache/2.0.53 (Unix) mod_python/3.1.4 Python/2.4.1
>>>
>>> mod_python works fine, however when I try to use Vampire I get a  
>>> seg fault:
>>>
>>> [Fri Oct 21 20:31:38 2005] [notice] mod_python: (Re)importing  
>>> module 'vampire'
>>> [Fri Oct 21 20:31:39 2005] [notice] child pid 23753 exit signal  
>>> Segmentation fault (11)
>>>
>>> I can't figure out what the source of the seg fault is.  Vampire  
>>> is in the sys.path.  The only thing I change in the .htaccess is  
>>> "myprob" to "vampire" for the PythonHandler, and I don't touch  
>>> the actual file (resource).  Any thoughts on the source of this  
>>> would be greatly appreciated.  Below are my .htaccess file and  
>>> myprob.py.
>>>
>>> Ian.
>>>
>>> .htaccess:
>>> SetHandler mod_python
>>> PythonHandler vampire
>>> PythonDebug On
>>>
>>> myprob.py:
>>> from mod_python import apache
>>>
>>> def handler(req):
>>>     req.content_type = "text/plain"
>>>     req.write("boo")
>>>     return apache.OK
>>>
>>> _______________________________________________
>>> Mod_python mailing list
>>> Mod_python at modpython.org
>>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>>
>



More information about the Mod_python mailing list