Project

General

Profile

[Invalid] (mod_fastcgi.c.2391) unexpected end-of-file (perhaps the fastcgi process died)

Added by ForexGG over 9 years ago

Installed lighttpd 1.4.37 on Debian 8 with armel packages:

lighttpd, php5-fpm, php5 and php5-mysqlnd

System info:


# uname -a
Linux localhost 2.6.32.9-default #3 Thu Dec 29 20:07:17 HKT 2011 armv5tejl GNU/Linux

Using Chrome Browser, connect the MariaDB installed on Windows 7.

All other PHP scripts running OK. But whenever I made the connection by "mysqli", it will generate the error below.


2015-10-22 17:03:24: (mod_fastcgi.c.2391) unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: unix:/var/run/php5-fpm.sock

Tried the exact same configuration and installation on a Debian x86 machine. Everything works fine.

Don't know what happened.

Here is my /etc/lighttpd/lighttpd.conf file:


server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
#       "mod_rewrite",
)

#server.document-root        = "/var/www/html" 
server.document-root        = "/mnt/sdcard/www/php" 
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log" 
server.pid-file             = "/var/run/lighttpd.pid" 
server.username             = "www-data" 
server.groupname            = "www-data" 
server.port                 = 80
server.dir-listing          = "enable" 

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/" 
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 


------------------------------------------------------------------------------------------
And the /etc/lighttpd/conf-enabled/15-fastcgi-php.conf

# -*- depends: fastcgi -*-
# /usr/share/doc/lighttpd/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi

## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server += ( ".php" =>
        ((
                "socket" => "/var/run/php5-fpm.sock",
                "broken-scriptfilename" => "enable" 
        ))
)

------------------------------------------------------------------------------------------

/etc/php5/fpm/php.ini


[PHP]

engine = On

short_open_tag = Off

asp_tags = Off

precision = 14

output_buffering = 4096

zlib.output_compression = Off

implicit_flush = Off

unserialize_callback_func =

serialize_precision = 17

disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,

disable_classes =
zend.enable_gc = On

expose_php = Off

max_execution_time = 30

max_input_time = 60

memory_limit = 128M

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

display_errors = Off

display_startup_errors = Off
log_errors = On

log_errors_max_len = 1024

ignore_repeated_errors = Off

ignore_repeated_source = Off

report_memleaks = On

track_errors = Off

html_errors = On

variables_order = "GPCS" 

request_order = "GP" 

register_argc_argv = Off

auto_globals_jit = On

post_max_size = 8M

auto_prepend_file =

auto_append_file =

default_mimetype = "text/html" 

default_charset = "UTF-8" 

doc_root =

user_dir =

enable_dl = Off

cgi.fix_pathinfo=1

file_uploads = On

upload_max_filesize = 2M

max_file_uploads = 20

allow_url_fopen = On

allow_url_include = Off

default_socket_timeout = 60

[CLI Server]
cli_server.color = On

[Date]

[filter]

[iconv]

[intl]

[sqlite]

[sqlite3]

[Pcre]

[Pdo]

[Pdo_mysql]
pdo_mysql.cache_size = 2000

pdo_mysql.default_socket=
[Phar]

[mail function]
SMTP = localhost
smtp_port = 25

mail.add_x_header = On

[SQL]
sql.safe_mode = Off

[ODBC]

odbc.allow_persistent = On

odbc.check_persistent = On

odbc.max_persistent = -1

odbc.max_links = -1

odbc.defaultlrl = 4096

odbc.defaultbinmode = 1

[Interbase]
ibase.allow_persistent = 1

ibase.max_persistent = -1

ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 

ibase.dateformat = "%Y-%m-%d" 

ibase.timeformat = "%H:%M:%S" 

[MySQL]
mysql.allow_local_infile = On

mysql.allow_persistent = On

mysql.cache_size = 2000

mysql.max_persistent = -1

mysql.max_links = -1

mysql.default_port =

mysql.default_socket =

mysql.default_host =

mysql.default_user =

mysql.default_password =

mysql.connect_timeout = 60

mysql.trace_mode = Off

[MySQLi]

mysqli.max_persistent = -1

mysqli.allow_persistent = On

mysqli.max_links = -1

mysqli.cache_size = 2000

mysqli.default_port = 3306

mysqli.default_socket =

mysqli.default_host =
mysqli.default_user =

mysqli.default_pw =

mysqli.reconnect = Off

[mysqlnd]
mysqlnd.collect_statistics = On

mysqlnd.collect_memory_statistics = Off

[OCI8]

[PostgreSQL]
pgsql.allow_persistent = On

pgsql.auto_reset_persistent = Off

pgsql.max_persistent = -1

pgsql.max_links = -1

pgsql.ignore_notice = 0

pgsql.log_notice = 0

[Sybase-CT]
sybct.allow_persistent = On

sybct.max_persistent = -1

sybct.max_links = -1

sybct.min_server_severity = 10

sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0

[browscap]

[Session]
session.save_handler = files

session.use_strict_mode = 0

session.use_cookies = 1

session.use_only_cookies = 1

session.name = PHPSESSID

session.auto_start = 0

session.cookie_lifetime = 0

session.cookie_path = /

session.cookie_domain =

session.cookie_httponly =

session.serialize_handler = php

session.gc_probability = 0

session.gc_divisor = 1000

session.gc_maxlifetime = 1440

session.referer_check =

session.cache_limiter = nocache
session.cache_expire = 180

session.use_trans_sid = 0

session.hash_function = 0

session.hash_bits_per_character = 5

url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" 

[MSSQL]
mssql.allow_persistent = On

mssql.max_persistent = -1

mssql.max_links = -1

mssql.min_error_severity = 10

mssql.min_message_severity = 10

mssql.compatibility_mode = Off
mssql.secure_connection = Off

[Assertion]

[COM]

[mbstring]

[gd]

[exif]

[Tidy]

tidy.clean_output = Off

[soap]
soap.wsdl_cache_enabled=1

soap.wsdl_cache_dir="/tmp" 
soap.wsdl_cache_ttl=86400

soap.wsdl_cache_limit = 5

[sysvshm]

[ldap]
ldap.max_links = -1

[mcrypt]

[dba]

[opcache]

[curl]

[openssl]


------------------------------------------------------------------------------------------
I tried to look into the source code at mod_fastcgi.c line 2391

Find that the error message generated because the toread was equal or less than 0.

When i tried to debug the toread, by the following code, before the if statement as below

        if (ioctl(hctx->fd, FIONREAD, &toread)) {
                if (errno == EAGAIN) return 0;
                log_error_write(srv, __FILE__, __LINE__, "sd",
                                "unexpected end-of-file (perhaps the fastcgi process died):",
                                fcgi_fd);
                return -1;
        }
//---------------------------------------------

        FILE* file;

        file = fopen("/var/log/lighttpd/debug.txt", "wt+");

        fprintf(file, "%s %d", "ss", toread);

//---------------------------------------------

        if (toread > 0) {
                char *mem;
                size_t mem_len;

                     .......

After recompiled the code, it won't write anything to the debug.txt file. the debug.txt was generated OK.

I was really confused, and had no clue why toread value won't output to the file.

Any help, are appreciated.

Thanks


Replies (4)

RE: (mod_fastcgi.c.2391) unexpected end-of-file (perhaps the fastcgi process died) - Added by stbuehler over 9 years ago

Did you check whether the FastCGI process (i.e. php) died? I'm not sure how that error message could have been more clear.

FILE* io uses buffers, and you didn't flush them or close the file.

RE: (mod_fastcgi.c.2391) unexpected end-of-file (perhaps the fastcgi process died) - Added by ForexGG over 9 years ago

Yes, the FastCGI (php5-fpm) child died. here is the log from /var/log/php5-fpm.log


[22-Oct-2015 17:03:25] WARNING: [pool www] child 10810 exited on signal 11 (SIGSEGV) after 465.701638 seconds from start
[22-Oct-2015 17:03:25] NOTICE: [pool www] child 11841 started

see the time that the log generated, right after the lighttpd error generated.

You are right, after I closed the file. the output of toread value is 0.

So do you think it is the bug from the lighttpd or php5-fpm? or maybe the configuration files were not set right?

This machine has 256M memory, I was thinking maybe the memory was too low. After I added 64M swap to it, still has the same problem.

RE: (mod_fastcgi.c.2391) unexpected end-of-file (perhaps the fastcgi process died) - Added by stbuehler over 9 years ago

you must be kidding.. php crashes with a segfault, and you ask whether this is a bug in lighttpd or php?

    (1-4/4)