php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50265 endless loop waiting for child process
Submitted: 2009-11-23 02:24 UTC Modified: 2009-12-05 01:00 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mg at fork dot pl Assigned:
Status: No Feedback Package: CGI/CLI related
PHP Version: 5.2.11 OS: Linux
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mg at fork dot pl
New email:
PHP Version: OS:

 

 [2009-11-23 02:24 UTC] mg at fork dot pl
Description:
------------
fast-cgi php process loops forever during wait()ing for child process while there's no more child processes. 

Actual result:
--------------
in cgi_main.c there's loop:

1631                 while (1) {
1632                     if (wait(&status) >= 0) {
1633                         running--;
1634                         break;
1635                     } else if (exit_signal) {
1636                         break;
1637                     }
1638                 }

wait returns -1 as strace shows:

wait4(-1, 0xbff2d2a4, 0, NULL)          = -1 ECHILD (No child processes)

and loop never breaks (as apparently exit_signal is set to 0).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-23 10:16 UTC] jani@php.net
Try enable fastcgi debugging with DEBUG_FASTCGI when you compile PHP and provide the log of the failing run.
 [2009-11-24 03:02 UTC] mg at fork dot pl
I rebuilt php and started up, but as I don't know what exactly causes the problem we'll have to wait until it happens...

I started it like
% PHP_FCGI_CHILDREN=2 PHP_FCGI_MAX_REQUESTS=100 php-cgi -e -b 127.0.0.1:30004 -c /.../php.ini

Process group 2720
Forking, 0 running
Forking, 1 running
Wait for kids, pid 2720
Forking, 1 running
Wait for kids, pid 2720
Forking, 1 running
Wait for kids, pid 2720
Forking, 1 running
Wait for kids, pid 2720


pstree -uap shows

`-php-cgi,2720 -e -b 127.0.0.1:30004 -c /.../php.ini
  |-php-cgi,13821 -e -b 127.0.0.1:30004 -c /.../php.ini
  `-php-cgi,13822 -e -b 127.0.0.1:30004 -c /.../php.ini
 [2009-11-24 20:20 UTC] jani@php.net
1 child is in endless loop or what? Try attach to such process with gdb and see what the backtrace says.
 [2009-11-24 22:00 UTC] mg at fork dot pl
My previous comment shows state BEFORE the problem hits. Many "forking" messages are because of low MAX_REQUEST limit.

When I attached to the process running inside the endless loop (it was before recompilation with DEBUG_FASTCGI) I got following bt

#0  0xffffe424 in __kernel_vsyscall ()                                                                                                                                                             
#1  0xb712fc6d in __libc_wait (stat_loc=0xbff2d2a4) 
at ../sysdeps/unix/sysv/linux/wait.c:32                                                                                                          
#2  0x0845e720 in main (argc=0, argv=Cannot access memory at address 0x4                                                                                                                             
) at /usr/src/debug/dev-lang/php-5.2.11/php-5.2.11/sapi/cgi/cgi_main.c:1632
 [2009-11-25 13:17 UTC] jani@php.net
Well, that means the child is running and this process is the main process waiting it to terminate. So is that child in endless loop or what? And if it is, why? That's the real problem here..
 [2009-11-25 23:04 UTC] mg at fork dot pl
The problem happens where there's NO child process (wait4 returns -1 with errno set to ECHILD).

It looks like child mysteriously vanished between fork() and wait().

Unfortunately I cannot easily reproduce the problem so we're still waiting for this to happen.

I think it may be important that called php script uses exec() to call some utilities.
 [2009-11-27 11:14 UTC] jani@php.net
Please let us know when you figure out how to reliably reproduce this.
Until that, do not change the status. Thank you.
 [2009-12-05 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC