het.oosten
het.oosten

Reputation: 885

python-openid cause segmentation fault on mod_wsgi

I am trying to get Facebook login working with Django. I tried Django-allauth and python-social-auth. Both work well with the dev server, but not in production with mod_wsgi.

I get an Apache2 500 error page.

In de logs I have errors like:

[Sat Sep 21 15:30:06 2013] [notice] child pid 27293 exit signal Segmentation fault (11)

[Sat Sep 21 15:30:04 2013] [error] [client 12.23.34.45] Premature end of script headers: wsgi.py
[Sat Sep 21 15:30:04 2013] [error] [client 12.23.34.45] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

When I remove the python-openid module everythings works as it should (I get the Django 500 error page, saying this module is missing, but no segfault in wsgi)

I use these wsgi directions in my httpd.conf:

WSGIDaemonProcess info user=info group=info threads=25
WSGIProcessGroup info

On the same server I have many other Django sites in production, all without problem (every site using a virtualenv).

I set loglevel to debug which gave me these extra messages:

[Sat Sep 21 15:59:19 2013] [debug] core.c(3126): [client 12.23.34.45] redirected from r->uri = /admin/
[Sat Sep 21 15:59:20 2013] [info] mod_wsgi (pid=28475): Attach interpreter ''.
[Sat Sep 21 15:59:20 2013] [info] mod_wsgi (pid=28475): Create interpreter 'www.mydomein.nl|'.
[Sat Sep 21 15:59:20 2013] [info] [client 12.23.34.45] mod_wsgi (pid=28475, process='info', application='mydomain.nl|'): Loading WSGI script '/home/info/wsgi.py'.

(thanks for the edit)

As suggested I change my httpd.conf into:

WSGIDaemonProcess info user=info group=info threads=25
WSGIProcessGroup info
WSGIApplicationGroup %{GLOBAL}

Unfortunately I still have the same problem.

EDIT:

The mod_wsgi docs suggest running GDB to debug. I got some info, but I dont understand the output:

#0  0x00007f5aea4db293 in __poll (fds=<value optimized out>, nfds=<value optimized out>, timeout=<value optimized out>)
    at ../sysdeps/unix/sysv/linux/poll.c:87
#1  0x00007f5aeae0b370 in apr_poll (aprset=0x7fffb31f7130, num=1, nsds=0x7fffb31f7178, timeout=<value optimized out>) at poll/unix/poll.c:120
#2  0x00007f5ae501d5af in wsgi_daemon_main (p=0x102e138, daemon=0x1093ec0) at mod_wsgi.c:10801
#3  wsgi_start_process (p=0x102e138, daemon=0x1093ec0) at mod_wsgi.c:11269
#4  0x00007f5ae5020351 in wsgi_manage_process (reason=<value optimized out>, data=0x1093ec0, status=<value optimized out>) at mod_wsgi.c:9761
#5  0x00007f5aeae064a1 in apr_proc_other_child_alert (proc=<value optimized out>, reason=<value optimized out>, status=<value optimized out>)
    at misc/unix/otherchild.c:115
#6  0x00000000004bb50f in ap_mpm_run (_pconf=<value optimized out>, plog=<value optimized out>, s=<value optimized out>) at prefork.c:1073
#7  0x000000000042e2b4 in main (argc=4, argv=0x7fffb31f7588) at main.c:753

EDIT2

When backtracing,I saw some expat line comming by. I therefore checked both expat versions:

[root@server info]# strings /etc/httpd/lib/libexpat.so.0 | grep expat_
expat_1.95.7


 pyexpat.version_info
(2, 0, 1)

Seems my apache install is outdated...

Upvotes: 0

Views: 422

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58523

Why mod_wsgi may crash covered in the FAQ for mod_wsgi.

In particular, you likely are using a C extension module which hasn't been written correctly to work in Python sub interpreters and so it crashes.

As explained in issues list for mod_wsgi, presuming that it is the only WSGI application running in that mod_wsgi daemon process, force it to run in the main interpreter, using:

WSGIApplicationGroup %{GLOBAL}

Upvotes: 1

Related Questions