Edit report at http://bugs.php.net/bug.php?id=29100&edit=1

 ID:               29100
 Comment by:       nasretdinov at gmail dot com
 Reported by:      pickleman78 at sbcglobal dot net
 Summary:          fread ignores memory_limit
 Status:           Bogus
 Type:             Bug
 Package:          Reproducible crash
 Operating System: WIndows XP
 PHP Version:      4.3.6

 New Comment:

The this is that this does not lead to normal Fatal error, but to a web
server/PHP uncatchable and undebuggable crash.


Previous Comments:
------------------------------------------------------------------------
[2004-07-12 19:20:10] [email protected]

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.

------------------------------------------------------------------------
[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/bug.php?id=29100&edit=1

Reply via email to