php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67320 Ignored sigpipes in php-fpm cause php to become unresponsive
Submitted: 2014-05-21 19:36 UTC Modified: 2023-12-03 22:46 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:4 (100.0%)
From: ryan at rmauger dot co dot uk Assigned: bukka (profile)
Status: Closed Package: FPM related
PHP Version: 5.5.12 OS: Linux / Debian 6/7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ryan at rmauger dot co dot uk
New email:
PHP Version: OS:

 

 [2014-05-21 19:36 UTC] ryan at rmauger dot co dot uk
Description:
------------
As sigpipe appears to be ignored (http://lxr.php.net/xref/PHP_TRUNK/sapi/fpm/fpm/fpm_main.c#1584) when a sigpipe is recieved, the fcgi_request here https://github.com/php/php-src/blob/master/sapi/fpm/fpm/fastcgi.c#L316 appears to always be null, and so all subsiquent requests to all workers via nginx are treated as bad gateway errors. 

Below is a backtrace from a worker where this has occured.

Core was generated by `/opt/php/sbin/php-fpm'.
Program terminated with signal 13, Broken pipe.
#0  0x00007ff6eb0160d0 in __write_nocancel () from /lib/libpthread.so.0
(gdb) bt
#0  0x00007ff6eb0160d0 in __write_nocancel () from /lib/libpthread.so.0
#1  0x0000000000b5e00a in safe_write (req=0x7fffcc4715e0, buf=0x58a8158, count=33520) at /usr/local/src/php-5.4.28/sapi/fpm/fpm/fastcgi.c:316
#2  0x0000000000b5fb4c in fcgi_write (req=0x7fffcc4715e0, type=FCGI_STDOUT, 
    str=0x58a8158 "<!DOCTYPE html>\n<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 7]>    <html class=\"no-js ie7 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 8]>    <html class=\"no-js ie8"..., len=33522) at /usr/local/src/php-5.4.28/sapi/fpm/fpm/fastcgi.c:1023
#3  0x0000000000b68d3b in sapi_cgibin_single_write (
    str=0x58a8158 "<!DOCTYPE html>\n<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 7]>    <html class=\"no-js ie7 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 8]>    <html class=\"no-js ie8"..., str_length=33522, tsrm_ls=0x2463510) at /usr/local/src/php-5.4.28/sapi/fpm/fpm/fpm_main.c:279
#4  0x0000000000b68db7 in sapi_cgibin_ub_write (
    str=0x58a8158 "<!DOCTYPE html>\n<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 7]>    <html class=\"no-js ie7 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 8]>    <html class=\"no-js ie8"..., str_length=33522, tsrm_ls=0x2463510) at /usr/local/src/php-5.4.28/sapi/fpm/fpm/fpm_main.c:305
#5  0x0000000000a0a698 in php_output_op (op=0, 
    str=0x589fd88 "<!DOCTYPE html>\n<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 7]>    <html class=\"no-js ie7 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 8]>    <html class=\"no-js ie8"..., len=33522, tsrm_ls=0x2463510) at /usr/local/src/php-5.4.28/main/output.c:1093
#6  0x0000000000a080b5 in php_output_write (
    str=0x589fd88 "<!DOCTYPE html>\n<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 7]>    <html class=\"no-js ie7 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 8]>    <html class=\"no-js ie8"..., len=33522, tsrm_ls=0x2463510) at /usr/local/src/php-5.4.28/main/output.c:269
#7  0x00000000009ed1f0 in php_output_wrapper (
    str=0x589fd88 "<!DOCTYPE html>\n<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 7]>    <html class=\"no-js ie7 oldie\" lang=\"en\"> <![endif]-->\n<!--[if IE 8]>    <html class=\"no-js ie8"..., str_length=33522) at /usr/local/src/php-5.4.28/main/main.c:1868
#8  0x0000000000aa1426 in zend_print_zval_ex (write_func=0x9ed1b8 <php_output_wrapper>, expr=0x5815b18, indent=0) at /usr/local/src/php-5.4.28/Zend/zend.c:330
#9  0x0000000000aa13a1 in zend_print_zval (expr=0x5815b18, indent=0) at /usr/local/src/php-5.4.28/Zend/zend.c:311
#10 0x0000000000aa0170 in zend_print_variable (var=0x5815b18) at /usr/local/src/php-5.4.28/Zend/zend_variables.c:154
#11 0x0000000000b3db7d in ZEND_ECHO_SPEC_CV_HANDLER (execute_data=0x7ff6f03f6710, tsrm_ls=0x2463510) at /usr/local/src/php-5.4.28/Zend/zend_vm_execute.h:26793
#12 0x0000000000ae818b in execute (op_array=0x426d618, tsrm_ls=0x2463510) at /usr/local/src/php-5.4.28/Zend/zend_vm_execute.h:410
#13 0x0000000000aa5438 in zend_execute_scripts (type=8, tsrm_ls=0x2463510, retval=0x0, file_count=3) at /usr/local/src/php-5.4.28/Zend/zend.c:1315
#14 0x00000000009eea06 in php_execute_script (primary_file=0x7fffcc473630, tsrm_ls=0x2463510) at /usr/local/src/php-5.4.28/main/main.c:2502
#15 0x0000000000b6d2bb in main (argc=3, argv=0x7fffcc473868) at /usr/local/src/php-5.4.28/sapi/fpm/fpm/fpm_main.c:1933
(gdb) x 0x7fffcc4715e0
0x7fffcc4715e0:	0x00000000


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-07 21:16 UTC] iiridayn at skylords dot com
After experiencing the issue for months - this is what's causing my production server to lock up. Nice to know now.
 [2021-12-06 23:12 UTC] bukka@php.net
-Assigned To: +Assigned To: bukka
 [2021-12-06 23:12 UTC] bukka@php.net
Just an update of the links in the bug as this seem to be reported against 5.4:

https://github.com/php/php-src/blob/PHP-5.4/sapi/fpm/fpm/fpm_main.c#L1584
https://github.com/php/php-src/blob/PHP-5.4/sapi/fpm/fpm/fastcgi.c#L316

There's a reason why SIGPIPE is blocked but it might still need a look to see if there is anything we can do about this issue.
 [2023-12-03 22:46 UTC] bukka@php.net
-Status: Assigned +Status: Closed
 [2023-12-03 22:46 UTC] bukka@php.net
I just had a look on this one and it seems to me like another issue that got fixed during PHP 7 (don't remember exact version) but should be fixed in PHP 8. I don't think blocking SIGPIPE was the reason for this and it wouldn't really make much sense to me why it should.

I will close this but in case you still experience an issue in PHP 8.2+, please open a new GitHub issue and we will deal with that.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 19:01:26 2024 UTC