mod-wsgi segmentation fault under debian/apache2

3

I'm trying to get mod-wsgi running under Apache2 with an eye towards using it with Django.

Right now I'm just getting a basic app running and am getting a segmentation fault. Any suggestions on how to track down the error would be appreciated, I'm stuck.

This is under Debian/Lenny, stock versions of Apache, mod-wsgi, and python 2.5. I've checked and mod-wsgi is linked against /usr/lib/libpython2.5.so.1.0. I originally had python 2.4 installed, but removed it just in case it was picking up the wrong version.

The script file is:

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

My config is:

WSGIScriptAlias /myapp /var/www/test/myapp.wsgi

<Directory /var/www/test/myapp.wsgi>
Order allow,deny
Allow from all
</Directory>

And when I try to view the url I see this in the apache error log.

[Fri Nov 19 09:29:58 2010] [info] mod_wsgi (pid=7190): Create interpreter 'morpheus.gateway.2wire.net|/myapp'.
[Fri Nov 19 09:29:58 2010] [info] mod_wsgi (pid=7331): Attach interpreter ''.
[Fri Nov 19 09:29:58 2010] [notice] child pid 7190 exit signal Segmentation fault (11)

Python seems to work fine otherwise, I've run my django app under the built-in server with no problems.

Just FYI, I started out trying to get my django app running, but ran into this error:

[Fri Nov 19 08:25:08 2010] [info] mod_wsgi (pid=6861): Create interpreter 'morpheus.gateway.2wire.net|/curtana'.
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70] mod_wsgi (pid=6861): Exception occurred processing WSGI script '/var/data/curtana/curtana.wsgi'.
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70]   File "/var/data/curtana/curtana.wsgi", line 1
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70]      import sys
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70]           ^
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70]  SyntaxError: invalid syntax

Which seems let me to try the basic app.

Thanks for any suggestions.

Edit to add, here's a backtrace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb751a700 (LWP 8092)]
0xb6b3a920 in PyParser_AddToken (ps=0x8543f90, type=8, str=0x845a480 ")", 
    lineno=1, col_offset=39, expected_ret=0xbfffe378) at ../Parser/parser.c:274
274     ../Parser/parser.c: No such file or directory.
        in ../Parser/parser.c
(gdb) backtrace
#0  0xb6b3a920 in PyParser_AddToken (ps=0x8543f90, type=8, str=0x845a480 ")", 
    lineno=1, col_offset=39, expected_ret=0xbfffe378) at ../Parser/parser.c:274
#1  0xb6b3ab86 in parsetok (tok=0x8535460, g=<value optimized out>, start=257, 
    err_ret=0xbfffe360, flags=<value optimized out>)
    at ../Parser/parsetok.c:194
#2  0xb6bec5eb in PyParser_SimpleParseFileFlags (fp=0x84f3288, 
    filename=0x85301b0 "/var/www/test/myapp.wsgi", start=257, flags=0)
    at ../Python/pythonrun.c:1404
#3  0xb6c76877 in ?? () from /usr/lib/apache2/modules/mod_wsgi.so
#4  0x084f3288 in ?? ()
#5  0x085301b0 in ?? ()
#6  0x00000101 in ?? ()
#7  0x00000000 in ?? ()
python
apache2
mod-wsgi
asked on Stack Overflow Nov 19, 2010 by Eddie • edited Nov 19, 2010 by Eddie

1 Answer

2

Read through mod_wsgi documentation looking for where it discusses crashes. Start with:

http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions http://code.google.com/p/modwsgi/wiki/InstallationIssues

Likely a clash with mod_python or due to wrong Python installation being found at run time.

For later, do checks of installation as outlined in:

http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation


UPDATE 1

The generation of a stack trace as mentioned in comment is documented in:

http://code.google.com/p/modwsgi/wiki/DebuggingTechniques

answered on Stack Overflow Nov 19, 2010 by Graham Dumpleton • edited Nov 19, 2010 by Graham Dumpleton

User contributions licensed under CC BY-SA 3.0