php-fpm子进程退出信号11

Our application run on docker container on AWS. Operating system: Ubuntu 14.04.2 LTS Nginx Version: nginx/1.4.6 (Ubuntu) Memcached Version: memcached 1.4.14 PHP Version: PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul 2 2015 15:23:08) System Memory: 7.5 GB

We get blank pages and 404 Error less frequently. While checking the logs found that php-child process is killed and it seems that memory is mostly used by memcache and php-fpm process and very low free memory.

memcache is configured to use 2GB memory.

Here is php www.conf

pm = dynamic
pm.max_children = 30
pm.start_servers = 9
pm.min_spare_servers = 4
pm.max_spare_servers = 14
rlimit_files = 131072 
rlimit_core = unlimited

Error logs

/var/log/nginx/php5-fpm.log 
[29-Jul-2015 14:37:09] WARNING: [pool www] child 259 exited on signal 11 (SIGSEGV - core dumped) after 1339.412219 seconds from start

/var/log/nginx/error.log 

2015/07/29 14:37:09 [error] 141#0: *2810 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: _, request: "GET /suggestions/business?q=Selectfrom HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "example.com", referrer: "http://example.com/"

/var/log/nginx/php5-fpm.log  
[29-Jul-2015 14:37:09] NOTICE: [pool www] child 375 started


/var/log/nginx/php5-fpm.log:[29-Jul-2015 14:37:56] WARNING: [pool www] child 290 exited on signal 11 (SIGSEGV - core dumped) after 1078.606356 seconds from start

Coredump

Core was generated by php-fpm: pool www.Program terminated with signal SIGSEGV, Segmentation fault.#0  0x00007f41ccaea13a in memcached_io_readline(memcached_server_st*, char*, unsigned long, unsigned long&) () from /usr/lib/x86_64-linux-gnu/libmemcached.so.10

dmesg

[Wed Jul 29 14:26:15 2015] php5-fpm[12193]: segfault at 7f41c9e8e2da ip 00007f41ccaea13a sp 00007ffcc5730ce0 error 4 in libmemcached.so.10.0.0[7f41ccad2000+32000]
[Wed Jul 29 14:28:26 2015] php5-fpm[12211]: segfault at 7f41c966b2da ip 00007f41ccaea13a sp 00007ffcc5730ce0 error 4 in libmemcached.so.10.0.0[7f41ccad2000+32000]
[Wed Jul 29 14:29:16 2015] php5-fpm[12371]: segfault at 7f41c9e972da ip 00007f41ccaea13a sp 00007ffcc5730b70 error 4 in libmemcached.so.10.0.0[7f41ccad2000+32000]
[Wed Jul 29 14:35:36 2015] php5-fpm[12469]: segfault at 7f41c96961e9 ip 00007f41ccaea13a sp 00007ffcc5730ce0 error 4 in libmemcached.so.10.0.0[7f41ccad2000+32000]
[Wed Jul 29 14:35:43 2015] php5-fpm[12142]: segfault at 7f41c9e6c2bd ip 00007f41ccaea13a sp 00007ffcc5730b70 error 4 in libmemcached.so.10.0.0[7f41ccad2000+32000]
[Wed Jul 29 14:37:07 2015] php5-fpm[11917]: segfault at 7f41c9dd22bd ip 00007f41ccaea13a sp 00007ffcc5730ce0 error 4 in libmemcached.so.10.0.0[7f41ccad2000+32000]
[Wed Jul 29 14:37:54 2015] php5-fpm[12083]: segfault at 7f41c9db72bd ip 00007f41ccaea13a sp 00007ffcc5730ce0 error 4 in libmemcached.so.10.0.0[7f41ccad2000+32000]

Please let me know if needs more informations

Thanks in advance

It can happen if php is unable to write session information to file By default it is /var/lib/php/session You can change it by using configuration session_save_path

https://serverfault.com/questions/427596/phpmyadmin-having-problems-on-nginx-and-php-fpm-on-rhel-6/429445

While googling for this same issue, and trying hard to find a solution that was not related to sessions (because I have ruled that out) nor to bad PHP code (because I have several websites running precisely the same version of WordPress, and none have issues... except for one), I came upon an answer telling that a possible solution did involve removing some buggy extension (usually memcache/d, but could be something else).

Since I had this same site working flawlessly on one Ubuntu server, when switching to a newer server, I immediately suspected that it was the migration from PHP 5.5 to 7 that caused the problem. It was just strange because no other website was affected. Then I remembered that another thing was different on this new server: I had also installed New Relic. This is both an extension and a small server that runs in the background and sends a lot of analytics data to New Relic for processing. Allegedly, it's a PHP 5 extension, but, surprisingly, it loads well on PHP 7, too.

Now here comes the tricky bit. At some point, I had installed W3 Total Cache for the WordPress installation of that particular website. Subsequently, I saw that the performance of that server was so stellar that W3TC was unnecessary, and simply stuck to a much simpler configuration. So I could uninstall W3TC. That's all very nice, but... I forgot that I had turned New Relic on W3TC, too (allegedly, it adds some extra analytics data to be sent to New Relic). When uninstalling W3TC, probably there was 'something' left on the New Relic configuration in my server which was still attempting to send data through the W3TC interface (assuming that W3TC has an interface... I really have no idea how it works at that level), and, because that specific bit of code was missing, the php_fpm handler for that website would fail... some of the time. Not all the time, because I'm assuming that, in most cases, nginx was sending static pages back. Or maybe php_fpm, set to 'recycle' after 100 calls or so, would crash-on-stop. Whatever exactly was happening, it was definitely related to New Relic — as soon as I removed the New Relic extension from PHP, that website went back to working normally.

Because this is such a specific scenario, I'm just writing this as an answer, in the remote chance that someone in the future googles for the exact problem.

In my case, it was caused by New Relic PHP Agent. Therefore for specific function that cause crash, I added this code to disable New Relic

if (function_exists('newrelic_ignore_transaction')) {
    newrelic_ignore_transaction();
}

refer: https://discuss.newrelic.com/t/how-to-disable-a-specific-transaction-in-php-agent/42384/2

I had this problem after installing xdebug, adding some properties to /etc/php/7.1/fpm/php.ini and restarting nginx. This is running on a Homestead Laravel box.

Simply restarting the php7.1-fpm service solved it for me.

You can generally find more details about those crashes by looking at your syslog (/var/log/syslog on linux, /var/log/system.log on mac os).

I had Sep 14 11:16:26 bob ReportCrash[89504]: Saved crash report for php-fpm[13757] version 0 to /Users/bob/Library/Logs/DiagnosticReports/php-fpm_2017-09-14-111626_MacBob.crash on my syslog, and the generated file contained everything to know which extension had troubles.

in my case i've deactivated the buffering function ob_start("buffer"); in my code ;)

In my case it was related to zend debug/xdebug. It forwards some tcp packets to IDE ( phpstorm ), that was not listening on this port ( debugging was off). The solution is to either disable these extensions or enable debug listening on the debugging port.

In our case it was caused by Guzzle + New Relic. In New Relic Agent changelog they've mentioned that in version 7.3 there was some Guzzle fix but even using the 8.0 didn't work so there is still something wrong. In our case this was happening only in 2 of our scripts that were using Guzzle. We found that there are two solutions:

  1. Set newrelic.guzzle.enabled = false in newrelic.ini . You will lose data in External Services tab this way but you might not need it anyway.
  2. Downgrade New Relic Agent to Version 6.x that somehow also works
  3. If you are reading this when they've released something newer that version 8.0 you could also try to update new relic agent to latest and maybe they fixed that

Possible problem php7.3 + xdebug, please change Xdebug 2.7.0beta1 on Xdebug 2.7.0rc1 or latest version xdebug

In my case it was xdebug , after uninstalling it got back to normal.