Forum Moderators: phranque

Message Too Old, No Replies

httpd Segmentation fault

         

AdrianBV

6:20 am on Jan 9, 2015 (gmt 0)

10+ Year Member



Hi guys.

I've been trying to solve this issue for about 2 months now.

I'm running xampp 5.6.3 64 bits ( apache 2.4.10 and php 5.6.3 )

In my apache error_log I get this:

[Mon Dec 29 20:53:49.172435 2014] [core:notice] [pid 15389] AH00051: child pid 15800 exit signal Segmentation fault (11), possible coredump in /opt/lampp/dumps/
[Mon Dec 29 20:53:51.174128 2014] [core:notice] [pid 15389] AH00051: child pid 15917 exit signal Segmentation fault (11), possible coredump in /opt/lampp/dumps/
[Mon Dec 29 20:54:02.185605 2014] [core:notice] [pid 15389] AH00051: child pid 15904 exit signal Segmentation fault (11), possible coredump in /opt/lampp/dumps/
[Mon Dec 29 20:54:03.186109 2014] [core:notice] [pid 15389] AH00051: child pid 15972 exit signal Segmentation fault (11), possible coredump in /opt/lampp/dumps/
[Mon Dec 29 20:54:07.190239 2014] [core:notice] [pid 15389] AH00051: child pid 15942 exit signal Segmentation fault (11), possible coredump in /opt/lampp/dumps/
[Mon Dec 29 20:54:22.205090 2014] [core:notice] [pid 15389] AH00051: child pid 15808 exit signal Segmentation fault (11), possible coredump in /opt/lampp/dumps/


This happens randomly and often ...
I made a core dump of apache and this is what i get:


Core was generated by `/opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f747374a7d6 in zend_stack_push () from /opt/lampp/modules/libphp5.so



I also tried xampp 5.5.19-0 ( apache 2.4.10 and php 5.5.19 ) and still i get the same errors in my error_log.

Any ideeas ?

lammert

11:26 pm on Jan 9, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi AdrianBV, first of all Welcome to WebmasterWorld!

This is a problem sometimes encountered when switching from Apache 2.2 to Apache 2.4. The reason is that Apache 2.2 default works with prefork where every httpd process is working in a fully separate process, whereas Apache 2.4 uses as default the MPM worker method. Only thread safe applications can be run in MPM worker mode and some PHP routines are not thread safe. That causes these segmentation faults.

If you add --with-mpm=prefork to your httpd startup everything should work fine.

AdrianBV

7:19 am on Jan 11, 2015 (gmt 0)

10+ Year Member



Hi. Thanks for your reply. Xampp uses by default the prefork mpm. I stoped httpd and started it anyway with the --with-mpm=prefork and still i get the same errors. Any other ideeas ?

AdrianBV

8:48 am on Jan 11, 2015 (gmt 0)

10+ Year Member



Just found out that in access_log I can add %P ( for child process id ).

Just restarted httpd and i'm going to let apache run it's course for a couple of hours till i make a script that parses the access_log and error_log to match segfault pids with requests in access_log and try to find similarities in child processes that crash. Wish me luck !

AdrianBV

1:38 pm on Jan 11, 2015 (gmt 0)

10+ Year Member



Ok ... I found that a script that handles a lot of traffic and gd intensive tasks was in 70% of the cases the last url request of every child httpd that gave a segfault.

From the tens of thousands of png's that are handled by that script less then 10 png's ( valid pngs ) caused the script to crash from time to time. ( sometimes they were ok, sometimes not, as far as I can tell, randomly ).

Deleting those png's coupled with adding imagedestroy after outputing or writing images dropped the segfaults from ~ 20 ... 30 per minute to about 1 ... 2 per minute.

I still get segfaults on that script on images that are perfectly valid and when I access them there ok and don't give any error/segfaults ... but i'm out of ideeas for now ...

lammert

4:24 pm on Jan 11, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you generate images on the fly? I have had problems with imagemagick in PHP with consuming more memory than available. I played with the memory_limit setting in php.ini to solve this. If PHP runs out of memory, the process shouldn't segfault though.

Are you on shared / VPS hosting? Some configurations kill processes automatically when the memory usage gets out of bounds and large non-system processes are the first to fall victim.

AdrianBV

5:12 pm on Jan 11, 2015 (gmt 0)

10+ Year Member



I'm on a dedicated server that has SSD storage, 8 GB DDR3 and a very good cpu.

I am generating images on the fly but with gd ( not imagemagick ).

My current memory limit is 128M ... I think that's enough since the images aren't that big ...

AdrianBV

4:09 pm on Jan 12, 2015 (gmt 0)

10+ Year Member



Small update for anyone who cares :)

For the preform mpm I had these settings:
StartServers 20
MinSpareServers 10
MaxSpareServers 100
MaxRequestWorkers 200
MaxConnectionsPerChild 0

First I changed MaxConnectionsPerChild to 100, thinking every child will serve 100 requests and die but it caused 100% segmentation fault.

After that, I changed them to these:
StartServers 10
MinSpareServers 10
MaxSpareServers 200
MaxRequestWorkers 256
MaxConnectionsPerChild 0

With these settings I managed to reduce from 40 .. 60 segfaults per hour to about 10 per hour. That's actually not bad ...