[mod_python] Segmentation fault when loading modules

Siddhartha Azad sid_docs at yahoo.com
Tue Sep 26 20:16:40 EDT 2006


Hi,
I have mod_python 3.2.10 built with apache 2.2.3 on RH
Linux. All was working fine for me until I changed my
directory structure (and hence the location of the
python modules). After doing so I apache started
seg-faulting. I  debugged with gdb -X and the
stacktrace points (as I suspected) to some
module-loading code that eventually crashes in some
pyexpat module due to a null string.

When I change my directory structure to what it was
before, everything works perfectly.

1. The directory structure that works:

   /dev/www/xyz.py
   /dev/www/modules/*.py

 When I invoke xyz.py from the browser (xyz.py imports
modules from "modules.py") everything works fine (i.e.
when the modules sub-directory is under within the
same parent directory as xyz.py.


2. The directory structure that doesn't work:

  /dev/www/xyz.py
  /dev/modules/*.py


Notice that the modules are no longer under the "www"
directory. Also, this only happens when my PYTHONPATH
actually has the "modules" directory (otherwise of
course I get an error from xyz.py that the import of
the modules failed).
Please help, I have been trying to fix this for 2 days
now and cannot find any references anyplace else.
The output from the apache error log and some walkback
from "gdb" follow.
Thanks, Sid.

APACHE ERROR LOG
----------------

[Tue Sep 26 20:12:47 2006] [notice] mod_python:
(Re)importing module 'mod_python.publisher'
[Tue Sep 26 20:12:47 2006] [notice] [client 127.0.0.1]
Publisher loading page /home/sid/dev/www/xyz.py
[Tue Sep 26 20:12:48 2006] [notice] child pid 32091
exit signal Segmentation fault (11)


WALKBACK FROM DEBUGGER
----------------------


#0  0x40167892 in PyString_FromString (str=0x0) at
Objects/stringobject.c:106
#1  0x401b8373 in PyModule_AddStringConstant
(m=0x4081e0ec,
   name=0x4092f6ba "XML_ERROR_UNBOUND_PREFIX",
value=0x0) at
Python/modsupport.c:531
#2  0x40913fa1 in initpyexpat () at
/usr/python-2.4.2/Python-2.4.2/Modules/pyexpat.c:1970
#3  0x401b2bad in _PyImport_LoadDynamicModule
(name=0xbfffadfc "pyexpat",
   pathname=0xbfffa960
"/usr/local/lib/python2.4/lib-dynload/pyexpat.so",
fp=0x8253090)
   at Python/importdl.c:53
#4  0x401af90d in load_module (name=0xbfffadfc
"pyexpat", fp=0x8253090,
   buf=0xbfffa960
"/usr/local/lib/python2.4/lib-dynload/pyexpat.so",
type=3, loader=0x1b)
   at Python/import.c:1677
#5  0x401b0615 in import_submodule (mod=0x40208de0,
subname=0xbfffadfc
"pyexpat",
   fullname=0xbfffadfc "pyexpat") at
Python/import.c:2262




More information about the Mod_python mailing list