I have been getting a segmentation fault when using
django.utils.feedgenerator to generate an RSS feed of my site. This
works fine with 'django-admin runserver', but when run under mod_python,
I get (in Apache's error log):
[Wed Feb 15 22:02:41 2006] [notice] mod_python: (Re)importing module
'django.core.handlers.modpython'
[Wed Feb 15 22:02:42 2006] [notice] mod_python: (Re)importing module
'django.core.handlers.modpython'
[Wed Feb 15 22:02:43 2006] [notice] child pid 21119 exit signal
Segmentation fault (11)
[Wed Feb 15 22:02:44 2006] [notice] child pid 21075 exit signal
Segmentation fault (11)
Bizarrely I only get this on my live server, not on my staging
mod_python server. I found an IRC transcript that suggested this was
something to do with also using mod_php on that Apache (which I do).
( http://simon.bofh.ms/logger/django/2006/01/23/ about two thirds of the
way down ).
In django/utils/feedgenerator.py if you comment out lines 24 and 25:
# from xml.dom import minidom
# from xml.parsers.expat import ExpatError
it works ! Those lines do not seem to be used.
Has anyone else encountered this ? Why those two imports if they are
not used ?
Best regards,
Graham.
99% of the time this is because you're running mod_php and mod_python
in the same Apache instance. Is this the case for you?
Jacob
I've added this to the mod_python documentation. If anybody has more
information (or other causes), please speak up.
http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
I'd like to suggest "Expat Causing Apache Crash", which explains
problems caused due to mismatches in the version of the "expat" library
embedded into Python and that linked into Apache, how to verifying if
expat is the problem and finally a resolution.
(http://www.dscpl.com.au/articles/modpython-006.html)
Another reading is mod_python FAQ Entry - mod_python and MySQLDb won't
work together
(http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp)
Then, a good way to obtain useful information that can be used to ask
for help is - first of all - check if mod_python works alone, without
involve Django. The procedure is detailed here:
http://www.dscpl.com.au/articles/modpython-001.html.
Again, it's useful to locate which is the problematic module (if it's
true that an imported module causes the crash) that make the
segmentation fault happen. For this I'd like to cite textually the
answer I had on mod_python mailing list (here is the whole thread, in
case anyone would care to read it,
http://www.modpython.org/pipermail/mod_python/2005-December/019647.html):
"Next step then would be to import into the handler of your test code,
the module which you specify needs to be imported in order to make
use of Django. If done in the test handler function, accessing the
test URL will cause it to be imported and if it does crash at that
point
you have confirmed that it is the actual import of the Django stuff
that
is the problem. If that is confirmed, then look internally at Django
and
see what module it imports, and instead of importing the Django top
level module, import what it imports. Gradually reduce the set of
imports
until it stops crashing so as to find the specific module that causes
the
problem. Drop down further into modules and look at their imports as
necessary.
This sort of process of elimination is the only way you are going to
be able to narrow it down. Unless you can determine precisely which
module is the issue, we aren't really going to be able to help."
This is all I gathered around.
HTH, regards
paolo wrote:
> Hi, I had problems running Django with mod_python, so I had the
> possibility to investigate and obtain some detailed info, which I'd
> like to share here.
>
> I'd like to suggest "Expat Causing Apache Crash", which explains
> problems caused due to mismatches in the version of the "expat" library
> embedded into Python and that linked into Apache, how to verifying if
> expat is the problem and finally a resolution.
> (http://www.dscpl.com.au/articles/modpython-006.html)
>
Commenting out this line in feedgenerator.py fixes my problem, so that
does seem to be the cause:
from xml.parsers.expat import ExpatError
An expat version mismatch would also explain why it works with
mod_python on my staging server (which is a more recent build).
This evening I will check the expat versions and try rebuilding Apache
as advised in the link, and post my results.
Thanks very much.
Graham.
Graham King wrote:
>
>
> paolo wrote:
>
>>Hi, I had problems running Django with mod_python, so I had the
>>possibility to investigate and obtain some detailed info, which I'd
>>like to share here.
>>
>>I'd like to suggest "Expat Causing Apache Crash", which explains
>>problems caused due to mismatches in the version of the "expat" library
>>embedded into Python and that linked into Apache, how to verifying if
>>expat is the problem and finally a resolution.
>>(http://www.dscpl.com.au/articles/modpython-006.html)
>>
>
That was my problem. Python was using expat 1.95.8, and Apache was
symlinked to 1.95.7.
I upgraded expat ('emerge expat' on Gentoo), restarted Apache, and it
now works fine.
I've added a comment to
http://www.djangoproject.com/documentation/modpython/
Thanks for the help.
Graham.
Thanks very much for this fine collection of information and links.
I've updated the documentation:
Excellent information. Having that stuff in the docs will save some
future django-nauts a bunch of time -- I spent a couple hours last
week on diagnosing the same issue.
I can't ditch PHP (yet), so I ended up setting up two separate
Apache instances running side-by-side to get around the mod_php
problem. Does anybody know of a better solution than that, short of
re-compiling PHP? Or which versions, distros, etc., this issue pops
up in?
Thanks,
--P
Paul Smith
pa...@blinkylights.org