Opened 12 years ago

Closed 9 years ago

#5354 closed (wontfix)

django imports minidom (which imports pyexpat) causing a modpython segfault on certain setups

Reported by: Antti Kaihola Owned by: Adrian Holovaty
Component: Core (Other) Version: master
Severity: Keywords: crash segfault
Cc: gkelly@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Changeset [5990] introduces and uses the django.utils.version.get_svn_revision() function which uses minidom.parse(). With certain combinations of Apache and mod_python versions, the version mismatch of libexpat used by both of them causes an Apache crash (segmentation fault on Linux). Apparently the problem has been worked around in Python 2.5.

For the inexperienced mod_python user this problem can be really hard to track down, since the symptoms are just empty web pages from the server and segmentation faults with no additional explanation in the Apache error log.

Would it be wise to avoid using minidom to avoid potential frustration for new users who might have a problematic setup?

Currently minidom is only used in get_svn_revision() and the isValidHTML() and isWellFormedXml() functions in django.core.validators. Maybe these cases could be solved with other tools?

Change History (10)

comment:1 Changed 12 years ago by anonymous

comment:2 Changed 12 years ago by James Bennett

Resolution: invalid
Status: newclosed

Problems with expat and mod_python are already documented.

comment:3 Changed 11 years ago by gkelly

Cc: gkelly@… added
Resolution: invalid
Status: closedreopened

Reopening. This is a hard problem to solve, even given the solution linked to in the docs. Recompiling Python and/or Apache to match specific versions of a 3rd party library is no easy task, especially for those that use pre-packaged linux distros.

Also of note is that the docs say "It may be because your Python code is importing the “pyexpat” module..." when in fact, the Django core is now importing it.

comment:4 Changed 11 years ago by gkelly

The following command seems to do the same thing. I'll work on converting into Python. It's similar to the method currently used in django.utils.version.get_svn_revision, but doesn't import minidom.

find . -name entries | grep '\.svn/entries$' | xargs grep -h committed-rev | cut -f2 -d'"' | sort -nr |head -1

comment:5 Changed 11 years ago by gkelly

Nevermind, the above comment is already being used in django.utils.version.get_svn_revision. It's just for older versions of subversion that is falls back to using minidom. (Should have read the wonderful code comments closer.)

I was able to resolve this by using a Django svn export, rather than checkout. That way, there is no .svn info, so it falls back to SVN-unknown. Another solution would be to upgrade the version of subversion used to utilize the newer .svn/entries file format.

comment:6 Changed 11 years ago by Chris Beaven

Summary: after [5990] mod_python segfault on certain setupsdjango imports minidom (which imports pyexpat) causing a modpython segfault on certain setups
Triage Stage: UnreviewedDesign decision needed

The decision is whether we want to change the code or just change documentation.

comment:7 Changed 11 years ago by Antti Kaihola

I vote for changing the code. I consider myself a fairly smart troubleshooter, and I was clueless for quite a while because it wasn't obvious at all whether it was Apache, mod_python, Python, Django, the OS or some random library causing the problem.

If people do exactly according to tutorials and documentation, and they just get blank pages, they might just turn away from Django.

An easy work-around from Django developers will save users from lots of trouble.

comment:8 Changed 10 years ago by brbob

I believe I'm running into this problem now. What exactly is the solution? Why is SVN tied to this? Can I just wipe all the .svn files from the django checkout? If this post is an indication, this problem is still alive and troublesome.

p.s. this page comes up for some searches for this error.

comment:9 Changed 10 years ago by brbob

Also, if its any help, I only get this segmentation fault when I include a cached_backend in my settings, otherwise its fine.

comment:10 Changed 9 years ago by Alex Gaynor

Resolution: wontfix
Status: reopenedclosed

mod_python is no longer a reccomended deployment and this is fixed in recent versions of python, wontfixing.

Note: See TracTickets for help on using tickets.
Back to Top