CoreDumpDirectory isn't working on ubuntu; getting segmentation fault in apache2 error log

Question:

I am not able to log the apache2 crashes in CoreDumpDirectory on ubuntu 10.10. I am using Django 1.2.3 and apache2 with mod_wsgi. I followed the steps listed in response to this question but to no avail. I added – CoreDumpDirectory /var/cache/apache2/
at the end of apache2.conf file and then after executing
'ulimit -c unlimited', restarted the apache server. Then I replicated the condition that causes apache error log to show- "child pid 27288 exit signal Segmentation fault (11)" but there is no mention of apache2 logging that crash in CoreDumpDirectory and also there is nothing in /var/cache/apache2.

Asked By: arank

||

Answers:

I was able to solve this problem. The issue was with PyLucene environment being initialized on the run time. I was executing initvm() call everytime a request comes and it was causing segmentation fault. This link directed that I should do it in .wsgi file and after I did that there were no segmentation faults.

Answered By: arank

I also ran into this problem of mod_wsgi children not dumping core. Long story short: You need to edit /etc/sysctl.conf and set fs.suid_dumpable=2.

Long story:

Linux prevents dumping core for processes that started as root and then dropped privileges. (This is a security feature, so SUID executables don’t leak their memory to the user). Setting suid_dumpable=2 means that core files will be owned by root, so there’s no direct security problem there either.

Why this affects mod_wsgi? Apparently mod_wsgi’s child processes are forked off from Apache’s main process. Apache usually starts up as root, since it needs to bind privileged port numbers like 80, and then drops privileges.

(Original bug report: https://code.google.com/p/modwsgi/issues/detail?id=247)

Answered By: intgr