Forum

PHP FastCGI daemon exited with code 32512

Palatinux
26 November 2011, 01:29
Hiawatha version: Hiawatha v7.8.1
Operating System: Fortress Linux
PHP version: PHP 5.4.0-rc1-pl0-Fortress_Linux (cli) (built: Nov 25 2011 02:12:53)


Hi Hugo,

For some reason, php-fcgi exits with the following error:

starting PHP FastCGI daemons'
'PHP FastCGI daemon exited with code 32512'


I'm using the hardened Hiawatha version for Fortress Linux, but I had the same issue with the original Hiawatha version. I think it has something to do with the child processes, but exporting the number of allowed child processes has no effect. php-cgi -b 2005 works fine too.


strace:

 write(2, "starting PHP FastCGI daemons", 28starting PHP FastCGI daemons) = 28
write(2, "\n", 1
) = 1
open("/var/log/hiawatha/php-fcgi.log", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1074, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x699920167000
fstat(3, {st_mode=S_IFREG|0644, st_size=1074, ...}) = 0
lseek(3, 1074, SEEK_SET) = 1074
time([1322266750]) = 1322266750
open("/etc/localtime", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=2917, ...}) = 0
fstat(4, {st_mode=S_IFREG|0600, st_size=2917, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x699920166000
read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\r\0\0\0\r\0\0\0\0"..., 4096) = 2917
lseek(4, -1843, SEEK_CUR) = 1074
read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\16\0\0\0\16\0\0\0\0"..., 4096) = 1843
lseek(4, 2916, SEEK_SET) = 2916
close(4) = 0
munmap(0x699920166000, 4096) = 0
write(3, "Sat 26 Nov 2011 01:19:10 +0100|s"..., 60) = 60
close(3) = 0
munmap(0x699920167000, 4096) = 0
open("/usr/bin/php-cgi", O_RDONLY) = 3
close(3) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x6999201689f0) = 1862
rt_sigprocmask(SIG_BLOCK, [CHLD], [], = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, = 0
nanosleep({1, 0}, {0, 998289075}) = ? ERESTART_RESTARTBLOCK (To be restarted)
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1862, si_status=127, si_utime=0, si_stime=0} (Child exited) ---
restart_syscall(<... resuming interrupted call ...>) = 0
wait4(1862, [{WIFEXITED(s) && WEXITSTATUS(s) == 127}], WNOHANG, NULL) = 1862
write(2, "PHP FastCGI daemon exited with c"..., 41PHP FastCGI daemon exited with code 32512) = 41
write(2, "\n", 1
) = 1
open("/var/log/hiawatha/php-fcgi.log", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1134, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x699920167000
fstat(3, {st_mode=S_IFREG|0644, st_size=1134, ...}) = 0
lseek(3, 1134, SEEK_SET) = 1134
time([1322266751]) = 1322266751
stat("/etc/localtime", {st_mode=S_IFREG|0600, st_size=2917, ...}) = 0
write(3, "Sat 26 Nov 2011 01:19:11 +0100|P"..., 69) = 69
close(3) = 0
munmap(0x699920167000, 4096) = 0
open("/var/run/php-fcgi.pid", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
close(3) = 0
exit_group(0) = ?



Maybe you could help me with this one
Hugo Leisink
26 November 2011, 17:24
It's not Hiawatha's php-fcgi that exited with 32512, it's PHP (php-cgi). Therefor, stracing php-fcgi will not help you. I have no idea why PHP exists with that exit code.
Palatinux
6 December 2011, 01:08
I've send you an email with the solution. Can you post it here? I can't because it's seen as spam.

thanks
Palatinux
6 December 2011, 16:53
I've looked into your php-fgci sourcecode and it indeed only forwards the php-cgi error. But running php-cgi -b 127.0.0.1:2005 runs without problems. Child processes seem to hang.

It was solved by upgrading PHP to the latest version.
Palatinux
6 December 2011, 18:06
The script can make it easier for users to debug their php-cgi. I will show the real errors generated by php-cgi instead of just error codes.
Adjust it to your system and try it out.

#!/bin/bash
BIND=127.0.0.1:9000
USER= nobody
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0

start() {
echo -n "Starting PHP FastCGI: "
start-stop-daemon --quiet --start --background --user "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
RETVAL=$?
echo "$PHP_CGI_NAME."
}
stop() {
echo -n "Stopping PHP FastCGI: "
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
echo "$PHP_CGI_NAME."
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL

Palatinux
7 December 2011, 22:33
Hi Hugo,

I finally found the problem. Code 32512 and 256 have something to do with denied reading permissions. It would be nice if php-fgci checks certain files and paths before it tries to start. Both php-fgci and php-cgi only produce cryptic or no error messages, which makes it very difficult to solve issues, even for us experts.

Is it possible to include these checks in version 8? It are just a few extra lines in php-fgci.c (assuming user "nobody" is used to spawn the main php-cgi processes and it child processes:

* is /etc/password readable by user nobody?
* is /etc/hiawatha/php-fgci.conf readable by user nobody?
* can user nobody execute /usr/sbin/php-cgi ?
* can user nobody read /dev/null ?
This topic has been closed.