[FASTCGI] cgi-fcgi stuck at 100% CPU in __kernel_vsyscall ()

Dmitry vdb at mail.ru
Fri Feb 19 12:56:12 EST 2010


Hello,

I am using simple webserver together with php_5_3_fpm (from SVN) and 
cgi-fcgi from fcgi-2.4.1-SNAP-0910052249. cgi-fcgi is patched with the 
small patch:

diff -uNrbB fcgi-2.4.1-SNAP-0910052249.org/cgi-fcgi/cgi-fcgi.c 
fcgi-2.4.1-SNAP-0910052249/cgi-fcgi/cgi-fcgi.c
--- fcgi-2.4.1-SNAP-0910052249.org/cgi-fcgi/cgi-fcgi.c	2009-10-06 
05:31:59.000000000 +0400
+++ fcgi-2.4.1-SNAP-0910052249/cgi-fcgi/cgi-fcgi.c	2009-12-13 
14:46:28.000000000 +0300
@@ -703,9 +708,6 @@
                  fprintf(stderr, "Number of servers must be greater 
than 0\n");
                  err++;
              }
-        } else {
-            fprintf(stderr, "Unknown argument %s\n", argv[i]);
-            err++;
          }
      }
      if(*doStartPtr && *appPathPtr == 0) {
@@ -748,6 +750,7 @@
      FCGI_BeginRequestRecord beginRecord;
      int	doBind, doStart, nServers;
      char appPath[MAXPATHLEN], bindPath[MAXPATHLEN];
+    struct timeval fd_read_timeout = { 10,0 };

      if(ParseArgs(argc, argv, &doBind, &doStart,
  		   (char *) &bindPath, (char *) &appPath, &nServers)) {
@@ -856,7 +859,9 @@
  	 * NULL = wait forever (or at least until there's something
  	 *        to do.
  	 */
-        OS_DoIo(NULL);
+        /* OS_DoIo(NULL); */
+
+        OS_DoIo(&fd_read_timeout);


First chunk is needed in order to correctly process QUERY_STRING with 
uninitialized variables like /?xxx. cgi-fcgi exits with error if there 
is no '=' sign after the name of variable. /?xxx=yyy is fine.

Second chunk is my attempt to solve the problem with endless loop and 
100% CPU usage. But it doesn't help.

Every day one or two cgi-fcgi processes stuck at 100% CPU for a long 
time. This is `ps auxwww` output:

1001     19832 98.8  0.0   1792   428 ?        R    11:45  15:49 
/usr/local/bin/cgi-fcgi -bind -connect /home/user/php-fpm.sock 
/var/vhosts/user/index.php

Trying to debug:

# gdb /usr/local/bin/cgi-fcgi 19832
GNU gdb Fedora (6.8-37.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...
(no debugging symbols found)
Attaching to program: /usr/local/bin/cgi-fcgi, process 19832
Reading symbols from /lib/libnsl.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols 
found)...done.
Loaded symbols for /lib/ld-linux.so.2
(no debugging symbols found)
0xffffe405 in __kernel_vsyscall ()
(gdb) bt
#0  0xffffe405 in __kernel_vsyscall ()
#1  0x00cd488d in ___newselect_nocancel () from /lib/libc.so.6
#2  0x0804ed73 in OS_DoIo ()
#3  0x0804a588 in main ()
(gdb) n
Single stepping until exit from function __kernel_vsyscall,
which has no line number information.
0x00cd488d in ___newselect_nocancel () from /lib/libc.so.6
(gdb) n
Single stepping until exit from function ___newselect_nocancel,
which has no line number information.
0x0804ed73 in OS_DoIo ()
(gdb) s
Single stepping until exit from function OS_DoIo,
which has no line number information.
0x0804a588 in main ()
(gdb) s
Single stepping until exit from function main,
which has no line number information.
Quit

How can I solve this problem?

-- 
Dmitry


More information about the FastCGI-developers mailing list