#29100 [Opn->Bgs]: fread ignores memory_limit

From: Date: Mon, 12 Jul 2004 17:20:12 +0000
Subject: #29100 [Opn->Bgs]: fread ignores memory_limit
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-62103@lists.php.net to get a copy of this message
ID: 29100 Updated by: pollita@php.net Reported By: pickleman78 at sbcglobal dot net -Status: Open +Status: Bogus Bug Type: Reproducible crash Operating System: WIndows XP PHP Version: 4.3.6 New Comment: emalloc() deosn't *actually* try to allocate the memory. It checks your requested amount against the php.ini setting and if it's too high, throws a fatal error. It has to be a fatal error because your script has outrun its resources, and it's impossible to predict whether or not it can safely continue operations in that condition. Previous Comments: ------------------------------------------------------------------------ [2004-07-11 22:40:59] pickleman78 at sbcglobal dot net Description: ------------ I am getting a crash from PHP when I mistakenly attempt to read 1,761,607,681 bytes from an incoming socket. Now I would reasonably assume that since this is far above the memory limit set in my PHP.ini file memory_limit = 8M I would expect it to stop before even attempting to allocate such a rediculous ammount of memory for the script. In this case it fails with a FATAL: emalloc() unable to allocate 1761607681 bytes. Should this be what it does? I would expect it to issue an ERROR as opposed to crashing. Reproduce code: --------------- <?php $fp=fsockopen("http://php.net"); $data=fread($fp,1761607681); ?> Expected result: ---------------- It would be expected to receive an error as opposed to PHP trying to allocate this memory Actual result: -------------- Stated above, causes FATAL: emalloc() could not...... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29100&edit=1

« previous php.bugs (#62103) next »