|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37205 Serving binary content/images fails with "comm with server aborted" FastCGI err
Submitted: 2006-04-26 01:37 UTC Modified: 2006-05-04 07:58 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: phpbugs at thequod dot de Assigned: dmitry (profile)
Status: Closed Package: CGI/CLI related
PHP Version: 5CVS-2006-04-29 (CVS) OS: Ubuntu Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
34 + 3 = ?
Subscribe to this entry?

 [2006-04-26 01:37 UTC] phpbugs at thequod dot de
I've just tested PHP 5.1.3RC4-dev (cgi-fcgi) (built: Apr 
26 2006 01:25:05).

The problem I've found seems to be related to:
 - Reimplemented FastCGI interface. (Dmitry)

If I serve a binary file (image) through PHP, the 
communication with the fastcgi server gets broken.

Reproduce code:
#header('Content-Type: image/gif');
echo file_get_contents( '' );


#header('Content-Type: image/gif');
echo file_get_contents( '' );

This is my fastcgi startup script:
export PHPRC
exec /bin/php51_CVS-fcgi

This is how the server gets configured in /etc/apache2/mods-enabled/fastcgi.conf:
FastCgiServer /XXX/fcgi-scripts/webXXX/php5-fcgi-starter -user webXXX -group webXXX -pass-header HTTP_AUTHORIZATION -flush -idle-timeout 60

I've installed libapache2-mod-fastcgi 2.4.2-6 (Ubuntu Breezy).

Expected result:
Only the binary (image) data, without the "attached" "The 
server encountered an internal error or misconfiguration 
and was unable to complete your request." error message.

Actual result:
Binary data from the image and then the internal server 

These are errors from the error log:
[Wed Apr 26 03:16:46 2006] [error] [client] 
FastCGI: comm with 
server "/XXX/fcgi-scripts/webXXX/php5-fcgi-starter" 
aborted: protocol error: invalid version: 152 != 
(with the first URL provided above)

[Wed Apr 26 03:21:15 2006] [error] [client] 
(104)Connection reset by peer: FastCGI: comm with 
server "/XXX/fcgi-scripts/webXXX/php5-fcgi-starter" 
aborted: read failed
(with the second URL provided above)

My .configure:
./configure \
--prefix=/home/XXX/make/php5 \
--with-config-file-path=/etc/php5 \
--with-pear=/XXX/lib/php5 \
--enable-calendar \
--enable-exif \
--enable-fastcgi \
--enable-force-cgi-redirect  \
--enable-gd-native-ttf \
--enable-inline-optimization \
--enable-mbstring=all \
--enable-mbregex \
--enable-memcache \
--enable-memory-limit \
--enable-sockets \
--enable-track-vars \
--with-bz2 \
--with-dom \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv \
--with-imap \
--with-imap-ssl \
--with-jpeg-6b \
--with-jpeg-dir \
--with-kerberos \
--with-ldap \
--with-ldap-sasl \
--with-mcrypt \
--with-mysql \
--with-openssl \
--with-png-dir \
--without-mm \
--with-sqlite \
--with-pcre-regex \
--with-ttf \
--with-zlib \


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-26 01:39 UTC] phpbugs at thequod dot de
fixed summary
 [2006-04-26 11:09 UTC]
Fixed in CVS HEAD and PHP_5_1.
 [2006-04-29 16:15 UTC] phpbugs at thequod dot de
Thank you. It's fixed indeed for those cases, but I just 
experienced a similar problem, when POSTing to any page 
I've found.

It outputs the following at the end of the generated HTML:
<div class="label"><label for="blog_allowblogcss">Erlaube 
angepasste CSS Datei fr Blogs:</label></div>
<div class="input"><input name="blog_allowblogcss" 
type="checkbox" value<!DOCTYPE HTML PUBLIC "-//IETF//DTD 
HTML 2.0//EN">
<title>200 OK</title>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator, and inform them of the time the 
error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<address>Apache/2.0.54 (Ubuntu) mod_chroot/0.5 DAV/2 
mod_fastcgi/2.4.2 mod_jk2/2.0.4 mod_ssl/2.0.54 
OpenSSL/0.9.7g Server at Port 443</address>

It can be reproduced here with this script:

var_dump( $_POST );


<form action="<?php echo $_SERVER['REQUEST_URI'] ?>" 
        <input type="text" name="test_input" />
        <input type="submit" />


for( $i = 0; $i < 10000; $i++ )
        echo $i;

I'm using the latest CVS tag here (with your "real fix").
 [2006-04-29 17:40 UTC] phpbugs at thequod dot de
The current error in the Apache error log is:

(104)Connection reset by peer: FastCGI: comm with 
server "/XXX/fcgi-scripts/XXX/php5-fcgi-starter" aborted: 
read failed, referer: http://XXX

Sorry, I probably should have created a new bug for it.
 [2006-05-01 15:07 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-05-01 17:43 UTC] phpbugs at thequod dot de
There's no difference. In fact, no relevant file seems to 
have changed in the snapshot.

I've tried it though:
You can test it yourself on, where I've put the 
reproduce-script from above.
 [2006-05-02 17:57 UTC] phpbugs at thequod dot de
The problem only appears with a minimum of content in the 

Therefor I've added "displaying 10000 numbers" to the test 
script, without this, it does not happen.

Also the point of failure goes more backward (displays 
more numbers), if you add additional whitespace (\n) 
between them.
 [2006-05-03 17:42 UTC] phpbugs at thequod dot de
I've just tried current CVS again, which includes some 
fixes for FastCGI, but now the simple php script mentioned 
above just times out!

Error log:

FastCGI: comm with 
server "/XXX/fcgi-scripts/XXX/php5-fcgi-starter" aborted: 
idle timeout (60 sec)
FastCGI: incomplete headers (0 bytes) received from 
server "/XXX/fcgi-scripts/XXX/php5-fcgi-starter"
 [2006-05-04 04:02 UTC] phpbugs at thequod dot de
I've just tried current PHP_5_1 CVS again, and it works.

I must have messed up the last time, without using my 
usual configure options.

Thank you.
 [2006-05-04 07:11 UTC]
So close the bug, if it works.
 [2006-05-04 07:58 UTC] phpbugs at thequod dot de
Sorry, thought I've done this. Thank you!
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Sep 22 03:03:36 2021 UTC