|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45254 PHP does not time out when accepting for connections while working as FastCGI
Submitted: 2008-06-12 22:44 UTC Modified: 2008-07-23 01:00 UTC
Avg. Score:4.8 ± 0.4
Reproduced:8 of 8 (100.0%)
Same Version:3 (37.5%)
Same OS:2 (25.0%)
From: yurtesen at ispro dot net Assigned:
Status: No Feedback Package: CGI/CLI related
PHP Version: 5.2.6 OS: FreeBSD 6.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: yurtesen at ispro dot net
New email:
PHP Version: OS:


 [2008-06-12 22:44 UTC] yurtesen at ispro dot net
When apache worker mpm and fastcgi and php-cgi are used together, the php-cgi processes sometimes hang and do not exit ever.

I tried to backtrace the running process using 'gdb -q -p'

[Switching to LWP 100164]
0x28affbe9 in accept () from /lib/
(gdb) backtrace
#0  0x28affbe9 in accept () from /lib/
#1  0x28a4193a in accept () from /lib/
#2  0x082da06f in fcgi_accept_request ()
#3  0x082dc345 in main ()

It looks like once PHP enters to function to accept request, it never exits unless instructed to do so. These processes wait idle for hours and when I find them I have to kill them manually.

Reproduce code:
Setup apache worker mpm, fastcgi, and php to work together. Load it up with requests and restart/reload server or cancel the requests in the middle (I dont exactly know what is causing this but these are the most probable suspects in my opinion). Sometimes apache process quits without transfering any data to PHP (perhaps browser canceled, server reload/restart etc.) PHP processes stay waiting...

The problem does not exist when apache prefork mpm is used...

Expected result:
I expect that PHP would die after max_input_time passses...

Actual result:
PHP hangs and waits until killed manually...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-15 16:14 UTC] ruanchunping at gmail dot com
I use lighttpd1.4.19 + php-cgi (5.2.6) @ FreeBSD 7.0 amd64

I found that ,the *POST* request sometimes hangs for ever,  
the lighttpd status report:
handle-req	59339(time)
handle-req	58478
handle-req	57985
there are over 100 php-cgi processes in this status pre day.
i have to restart lighttpd every day.

these POST request are posting blog or uploading photos.
 [2008-07-13 21:47 UTC] s dot tretter at szene1 dot at
same problem, php just "hangs" and doesn't exit. the only possible solution to kill all php processes is "killall -9 php-cgi" a simple killall (without -9) doesn't help.

no idea what is causing the php process to hang but it doesn't help to increase or decrease the PHP_FCGI_CHILDREN and PHP_FCGI_MAX_REQUESTS variables. no solution found until yet, and I also have to restart apache every day and this is very annoying on a server farm with more than 30 web servers.

googled a lot of time, some people say there is a relation between an accepting socket and an loosy internet connection .. in case of a post request the php process could hang if there is no real syn packet or similar...

for other bug reports or people with similar problems just ask google for "fastcgi php hang"

sorry for my bad english ;)
 [2008-07-13 21:52 UTC] s dot tretter at szene1 dot at
sorry, some more information about my software setup:
using apache 2.2.6, but preforked. fastcgi 2.4.6, php 5.2.6 but problem exist with all php version i ever used.

my compile options for php:
'./configure' \
'--enable-fastcgi' \
'--enable-force-cgi-redirect' \
'--with-pcre-regex' \
'--without-sqlite' \
'--with-mysqli' \
'--with-gd' \
'--with-ttf' \
'--enable-exif' \
'--with-mcrypt' \
'--enable-mbstring' \
'--enable-spl' \
'--prefix=/usr/local/php5' \
'--with-zlib' \
'--enable-gd-native-ttf' \
'--enable-sockets' \
'--enable-soap' \
'--with-apxs2=/usr/local/apache2/bin/apxs' \
 [2008-07-23 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-05-30 22:06 UTC] fredric at drombolaget dot se
I have the exact same problem right now on our VPS.

The VPS is running Ubuntu 8.04 64 bit on OpenVZ. The install of the software is from Ubuntu standard repositories.

The software is:
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch mod_ssl/2.2.8 OpenSSL/0.9.8g

Occassionally a php-cgi process "hangs" or rather does absolutely nothing - but it does consume memory. As the number of processes approaches the 30:s the server starts dying from acute lack of memory.

killall -9 php-cgi is still all that get's us out of this mess. Restarting apache doesn't even work as it seems to be waiting for the php processes to die.
 [2009-05-31 07:23 UTC] yurtesen at ispro dot net
Hej Fredric,

I believe this problem is solved in 5.2.9 version already. Can you test that?

 [2009-11-15 22:27 UTC] andi at splitbrain dot org
I still seem to be affected by this bug using PHP 5.2.11 and lighttpd 1.4.19.

Unfortunately this bug is hard to reproduce especially since it happens on a production machine. Can someone confirm that a proposed fix was indeed placed in PHP 5.2.9?
 [2009-12-07 22:00 UTC] samkline at gmail dot com
Confirmed on php 5.3.1, lighttpd 1.4.24. From ~500,000 page requests, I get several dozen hanging processes per day.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 22:01:29 2024 UTC