Bug #1496: imagecreate seems to have a heinous memory problem
| From: | saurik at saurik dot com | Date: | Sun, 06 Jun 1999 18:19:55 +0000 |
| Subject: | Bug #1496: imagecreate seems to have a heinous memory problem | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6591@lists.php.net to get a copy of this message | ||
From: saurik@saurik.com
Operating system: RedHat RawHide 1.3.9 & Linux 2.2.9-ac1+Patches
PHP version: 3.0.8
PHP Bug Type: Misbehaving function
Bug description: imagecreate seems to have a heinous memory problem
One of my (ex-)users wrote the following script, and then started calling it with larger and larger
values for the x and y variables (apparently to see how high he could go before he crashed php).
When he got to 30000x30000 the system ran out of memory, and the kernel started killing processes to
keep the system running (machine became totally unusable). I didn't want to test this again
since I wanted to get the machine online and keep it that way for my other users to be able to check
their e-mail (I was down for quite a while since the fsck on the harddrives took a couple hours, and
RAID is reconstructing right now as I type this, and for some reason is keeping me from unmounting a
drive I need to unmount, which is causing even more problems :( ). I have 128 meg of memory, and
about a 128 meg of swap. My assuption was that imagecreate() doesn't do a free memory check
before trying to allocate memory for the image and simply assumes its process will get killed or
capped or something first.
<?php
/* usage
uhm..just use it
(c) Patrik Husfloen 1999
*/
function createImg($height, $width, $red, $green, $blue) {
Header("Content-type: image/gif");
$imageid = imagecreate($height,$width);
$colorid = ImageColorAllocate($imageid, $red, $green, $blue);
imagefill($imageid,0,0,$colorid);
ImageGif($imageid);
ImageDestroy($imageid);
}
createImg($x,$y,$r,$g,$b);
?>