ID:               49611
 User updated by:  d dot reade at readesresidential dot com
 Reported By:      d dot reade at readesresidential dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Filesystem function related
 Operating System: CentOS 5.3 x86
 PHP Version:      5.2.11
 New Comment:

Sorry, the script is integrated into our own Web Framework which
equates to tens of thousands of lines of code. :)

I didn't think this was relevant at the time as I thought it was PHP
related only, however our server runs cPanel 11. Today my host built us
a brand new server, with CentOS 5.3 and a CentOS kernel (as the other
one was a Xen Guest kernel).

I tried running the script, pointing it at a PNG file hosted on our
live box, and it completed no problem first time round. I tried again
and again and each time it was successful. This was done running it via
the PHP CLI but the remote server runs PHP 5.2.10. So I pointed the
script to a PNG located on the local host running PHP 5.2.11, different
IP address. Using the http:// address it failed, while using the direct
path, i.e. /home/user... works fine, every time (as it should do since
the header are related to HTTP traffic).

I've now renamed all our htaccess files to be sure nothing is being
caused by our scripts, which also ensures none of our scripts are
loading when the PNG is requested, but it still fails with the same
errors.

I reset Apache and PHP configurations to defaults, or at least to the
same default as cPanel specifies. Same error.

I can only think something is being done by cPanel/WHM to the config
files to cause this problem, but again it's only been happening since
PHP 5.2.11, thus why I thought it was a bug in the first instance.

I would like to see what cPanel come back with as one of their
developers is looking into this now, so please could you keep the ticket
open? I'll report back my findings soon.

Thanks.


Previous Comments:
------------------------------------------------------------------------

[2009-09-22 09:54:14] j...@php.net

I can not reproduce this. Please provide the full script that causes
this, including the $url..

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

[2009-09-21 08:11:21] d dot reade at readesresidential dot com

I have managed to replicate the issue, multiple times. Here's the
code:

<?
$array  =       array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);

foreach($array as $val) {
        
        $tmp    =       tempnam('/tmp', 'test_img_');
        
        $file   =       file_get_contents($url);
        
        file_put_contents($tmp, $file);
        
        $img    =       imagecreatefrompng($tmp);
        
        imagedestroy($img);
}
?>

In my case $url was the direct http:// path to the image, in this
instance a high quality PNG over 1MB in size.

The script repeats 80 times (to mimic what my scripts are trying to
do). After the first run it stated 15 out of 80 of the PNGs were invalid
PNG files. On the second run it said 12 were invalid. The results are
different each time.

The error generated by PHP is:

Warning: imagecreatefrompng() [function.imagecreatefrompng]:
'/tmp/test_img_92M2J2' is not a valid PNG file in
/home/readesre/public_html/dev/img.php on line 12

Warning: imagedestroy(): supplied argument is not a valid Image
resource in /home/readesre/public_html/dev/img.php on line 14

Here's the list of files from the tmp folder:

-rw-------  1 nobody nobody 1778247 Sep 21 09:01 test_img_92M2J2
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_bHZKlf
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_btMJcI
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_DctHCw
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_dnosxg
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_DOZKw1
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_DxQcqp
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_f95art
-rw-------  1 nobody nobody 1778247 Sep 21 09:01 test_img_H5SukI
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_LcT3ss
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_lkEMhQ
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_lucjnA
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_nksxx7
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_To6cXV
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_vEzSrY
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_vqmVzZ
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_x8cIzF
-rw-------  1 nobody nobody 1778247 Sep 21 09:01 test_img_XzAwHt
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_ZA0s5W
-rw-------  1 nobody nobody 1778247 Sep 21 09:01 test_img_ZgkSty
-rw-------  1 nobody nobody 1777966 Sep 21 09:01 test_img_zVa5gj

This is only a snippet of the full list, but notice the file sizes. The
files that are 1778247 in size contain the following header info:

HTTP/1.1 200 OK
Date: Mon, 21 Sep 2009 08:01:24 GMT
Server: Apache
Last-Modified: Fri, 18 Sep 2009 10:26:04 GMT
Accept-Ranges: bytes
Content-Length: 1777966
Cache-Control: max-age=2592000
Expires: Wed, 21 Oct 2009 08:01:24 GMT
Connection: close
Content-Type: image/png

�PNG

Followed by the rest of the PNG file...

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

[2009-09-20 23:03:15] ras...@php.net

It would be really helpful if you could create an actual script that
reproduces this.  It isn't until the 8th comment on this bug that we
learn that it only happens if you are doing a whole bunch of them
together.  Your original reproducing script not only didn't have any
network component, but it also didn't have anything about multiple
connections.

How are you doing these multiple connections?  Just a big loop around
file_get_contents?  The best way to report a bug is to simplify your
problem down into a script that we can run ourselves and see the
problem.  If we can see it, we can fix it.  Otherwise we are guessing as
to what might be happening on your end.

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

[2009-09-20 22:44:06] paj...@php.net

I was thinking about a bug the curl stream wrapper, but no. I can't
reproduce this problem either, no matter the web server/OS/platform.

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

[2009-09-20 22:21:10] d dot reade at readesresidential dot com

Sure, here it is:

'./configure' '--disable-pdo' '--enable-bcmath' '--enable-calendar'
'--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml'
'--enable-magic-quotes' '--enable-sockets' '--enable-zip'
'--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs'
'--with-freetype-dir=/usr' '--with-gd'
'--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr'
'--with-jpeg-dir=/usr' '--with-kerberos' '--with-libxml-dir=/opt/xml2/'
'--with-mcrypt=/opt/libmcrypt/' '--with-mysql=/usr'
'--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-png-dir=/usr'
'--with-t1lib=/usr' '--with-ttf' '--with-xpm-dir=/usr' '--with-zlib'
'--with-zlib-dir=/usr'

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/49611

-- 
Edit this bug report at http://bugs.php.net/?id=49611&edit=1

Reply via email to