|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-04 16:56 UTC] 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. It?s 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 PC?s (all PC?s 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 14:00:01 2025 UTC |
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--; } ?>