ID:               49501
 User updated by:  romain dot riviere at gmail dot com
 Reported By:      romain dot riviere at gmail dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         *General Issues
 Operating System: Gentoo Linux 32bit
 PHP Version:      5.2.10
 New Comment:

The problem still happens without --enable-debug.

I could reproduce the bug in CLI with a simple while(true). More
specifically (and with memory_limit=128M this time):

<?php
ini_set('display_errors',true);
if (isset($_GET['size']) && $_GET['size'] < 200) {
$mb = intval($_GET['size']);
}
else {
        $mb=125;
}

while(true) {
$var = '';
echo 'Memory limit: '.ini_get('memory_limit').'<br>';
for ($i=0; $i<=$mb; $i++) {
        $var.= str_repeat('a',1*1024*1024);
        echo memory_get_usage().'<br>';
}
echo 'String length: '. strlen($var);
}
?>

This script crashes after a few iterations with the message:

Fatal error: Out of memory (allocated 123469824) (tried to allocate
122683393 bytes) in /home/acrm/OF-svn/2.0/test.php on line 14
zend_mm_heap corrupted

The memory_get_usage() output increases until it busts the 128M limit.

Now, I'm not too familiar with PHP's memory management, but I find it
strange that the script should hog memory that way: shouldn't it free
some RAM when $var is reset to '' ?

At any rate, the initial issue remains, whether this one is related or
not.


Previous Comments:
------------------------------------------------------------------------

[2009-09-09 09:41:59] j...@php.net

You also seem to be using --enable-debug, does it happen without it?
And can you reproduce the same on command line?

------------------------------------------------------------------------

[2009-09-09 03:41:48] romain dot riviere at gmail dot com

Just to confirm: the problem is still present without pic.

------------------------------------------------------------------------

[2009-09-09 03:23:14] romain dot riviere at gmail dot com

I'm mentioning pic because it is the only thing slightly out of the
ordinary in this setup.

I am using pic because of disabled TEXTRELs in the PaX enabled kernel.
I'm willing to try without pic though. I'll add to this report in case
it changes anything.

------------------------------------------------------------------------

[2009-09-08 20:57:05] ras...@php.net

Are you saying you don't see it if you don't use --with-pic?

And I am curious, why do you want pic?  libphp5.so isn't a
general-purpose shared library that can be linked into many different
things.  It is a very targeted library compiled for a specific binary to
link and as such compiling it pic just adds unnecessary overhead.

------------------------------------------------------------------------

[2009-09-08 20:42:30] romain dot riviere at gmail dot com

The last line of the initial description should have read : PHP
compiled --with-pic.

For the record, the problem appeared in Drupal and was reported as
happening at zend_opcode.c:48. However, since it can obviously be
reproduced with something as simple as a string, I believe it is a more
general memory leak issue.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/49501

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

Reply via email to