In this guide we show how to get information from apache segmentation faults that come from python’s mod_wsgi.
Segmentation faults in apache from mod_wsgi don’t hint at all what causes them, so we cannot know how to solve them:
AH00052: child pid 9972 exit signal Segmentation fault (11)
In this guide we show how to get information from them. It is based on the official mod_wsgi guide, but updated, concise and tested with Debian. We assume you know how to configure apache with mod_wsgi, and that you have an existing configuration of your server.
The first thing to do is put mod_wsgi into embedded mode, because we want it to be in the same apache process, and daemon mode is not. This is how we do it: Remove
WSGIApplicationGroup from your apache’s virtualhost to be in embedded mode. And only if you were using
WSGIPythonHome /path/to/pyvenv in your
gdb (in Debian just
apt install gdb).
Run apache with
sudo gdb /usr/sbin/apache. Debian won’t allow you to run gdb correctly as it uses some environment variables in the configuration file; run gdb the following way:
source /etc/apache2/envvars sudo -E gdb /usr/sbin/apache
In gdb, write
run -X and press enter.
Access the web with your browser that generates the error, and see how in your terminal shows the faulty line.