ID: 42545
User updated by: netclone at bigmir dot net
Reported By: netclone at bigmir dot net
Status: Open
Bug Type: GD related
Operating System: Windows XP SP2
PHP Version: 5.2.4
New Comment:
crash after 50 min
<?php
$path = '.\\test_dir';
if (isset($argv[1])){$max=$argv[1]} else $max=1000000;
while ($max)
{ $cwd = $path.DIRECTORY_SEPARATOR.$max;
$res = @mkdir($cwd,0777,true);
if ($res)
{ //create here 200 empty JPG 256x256
for ($i=0;$i<250;$i++){
if ($imp = @imagecreatetruecolor(256,256)){
$file_name = $cwd.DIRECTORY_SEPARATOR."testimg$i.jpg";
imagejpeg($imp,$file_name,80);
imagedestroy($imp);
}
}
}; $max--;
}
?>
Previous Comments:
------------------------------------------------------------------------
[2007-09-05 10:03:10] netclone at bigmir dot net
I can see in performance monitor that PTE is slowly goes down
------------------------------------------------------------------------
[2007-09-04 16:56:42] netclone at bigmir dot net
Description:
------------
System halts, php hangs up - each file-resource handler becomes
invalid.
I'm using CLI php.exe to process image storage with JPG files with
approximately size 2-3Mb each. Script uses database dump file each line
of them points to physical file location. This dump has 4000-6000
records. Within cycle it reads one line from dump and call this code,
and writes result into log file. Its outputs ~180 files (~18Kb) per 3-5
sec. Crash becomes at ~ 4h of work. Looks like no more handles aviable.
We have same results on 4 PCs (all PCs new, just bayed week ago, all
systems has same configuration Core2Duo/3GHz/2Gb, firmly HP), running on
Windows XP SP2 (all updates installed), installed extensions
php_oci8.dll, php_gd2.
Reproduce code:
---------------
$url = {image}; $FileDir = {path} //code to read IN file and open log
@mkdir($FileDir, 0755, true);
if( file_exists($FileDir) ) {
$InputImage = @ImageCreateFromJPEG( $url )
$iw = ImageSX($InputImage); $ih = ImageSY($InputImage);
$ThumbImage = @imagecreatetruecolor(124, 82))
imagecopyresampled($ThumbImage, $InputImage,0, 0, 0, 0, 124, 82, $iw,
$ih);
ImageJPEG($ThumbImage, $thumbnail, 80 );
ImageDestroy($ThumbImage);
$rows = ceil($iw /256); $cols = ceil($ih /256);
for($i = 0; $i < $rows; $i++ ) for( $j = 0; $j < $cols; $j++ ){
if ($OutputImage = @ImageCreateTrueColor( 256,256 ) {
ImageCopy( $OutputImage, $InputImage, 0, 0, $x, $y, $cw, $ch );
ImageJPEG( $OutputImage, $OutputFile, 80 );
ImageDestroy($OutputImage);
}
ImageDestroy($InputImage);
}
Expected result:
----------------
images in correpsonding folders
Actual result:
--------------
~4h all is ok, but at nearly 2500-2700 image it's write in log
PHP Warning: imagejpeg(): Unable to open 'xxx.jpg' for writing:
Invalid argument in script.php on line xx
PHP Warning: fwrite(): supplied argument is not a valid stream
resource
PHP Warning: fclose(): supplied argument is not a valid stream
resource
System hangs on, you can't open or run anything and need to reboot.
During this time created ~720 000 images
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42545&edit=1