php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1496 imagecreate seems to have a heinous memory problem
Submitted: 1999-06-06 14:19 UTC Modified: 1999-06-18 15:48 UTC
From: saurik at saurik dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.8 OS: RedHat RawHide 1.3.9 & Linux 2.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: saurik at saurik dot com
New email:
PHP Version: OS:

 

 [1999-06-06 14:19 UTC] saurik at saurik dot com
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);
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-18 15:48 UTC] sas at cvs dot php dot net
Set your system limits properly. There is no excuse in not setting limits on a web server which allows execution of arbitrary PHP user scripts.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 11:00:01 2026 UTC